diff --git a/base/pkg_version.go b/base/pkg_version.go index 5379457..d924967 100644 --- a/base/pkg_version.go +++ b/base/pkg_version.go @@ -1,6 +1,10 @@ package base import ( + "fmt" + "path/filepath" + "strings" + "git.fsdpf.net/go/contracts" "github.com/samber/do" ) @@ -19,6 +23,22 @@ type PkgVersion struct { CreatedAt string `db:"created_at"` } +func (this PkgVersion) GetFilePath(prefix ...string) string { + return filepath.Join( + filepath.Join(prefix...), + this.Platform, + strings.Replace(this.FileName, ".", fmt.Sprintf("-%s.", this.Hash), 1), + ) +} + +func (this PkgVersion) GetSourceMapPath(prefix ...string) string { + return filepath.Join( + filepath.Join(prefix...), + this.Platform, + strings.Replace(this.SourceMapFileName, ".", fmt.Sprintf("-%s.", this.Hash), 1), + ) +} + func (this PkgVersion) GetFile(app *do.Injector) ([]byte, error) { if this.Id == 0 { return nil, contracts.ErrPkgUnknown