From 4869409bf7ddea6e24d02b7b8210e9ede143803a Mon Sep 17 00:00:00 2001 From: what Date: Fri, 22 Nov 2024 17:54:37 +0800 Subject: [PATCH] =?UTF-8?q?[feat]=20=E5=AE=8C=E5=96=84=20PkgVersion=20GetF?= =?UTF-8?q?ilePath=20GetSourceMapPath?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base/pkg_version.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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