From 6f5c443c815db96babc6b9fa16cd25d75097274e Mon Sep 17 00:00:00 2001 From: what Date: Sat, 23 Nov 2024 14:28:22 +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, 8 insertions(+), 12 deletions(-) diff --git a/base/pkg_version.go b/base/pkg_version.go index d924967..b082904 100644 --- a/base/pkg_version.go +++ b/base/pkg_version.go @@ -39,38 +39,34 @@ func (this PkgVersion) GetSourceMapPath(prefix ...string) string { ) } -func (this PkgVersion) GetFile(app *do.Injector) ([]byte, error) { +func (this PkgVersion) GetFile(app *do.Injector) (file string, err error) { if this.Id == 0 { - return nil, contracts.ErrPkgUnknown + return file, contracts.ErrPkgUnknown } res, ok := do.MustInvoke[contracts.GetResource](app)("PkgVersion") if !ok { - return nil, contracts.ErrResNotFound + return file, contracts.ErrResNotFound } - file := []byte{} - - _, err := res.GetDBTable().Where("id", this.Id).Value(&file, "file") + _, err = res.GetDBTable().Where("id", this.Id).Value(&file, "file") return file, err } -func (this PkgVersion) GetSourceMap(app *do.Injector) ([]byte, error) { +func (this PkgVersion) GetSourceMap(app *do.Injector) (file string, err error) { if this.Id == 0 { - return nil, contracts.ErrPkgUnknown + return file, contracts.ErrPkgUnknown } res, ok := do.MustInvoke[contracts.GetResource](app)("PkgVersion") if !ok { - return nil, contracts.ErrResNotFound + return file, contracts.ErrResNotFound } - file := []byte{} - - _, err := res.GetDBTable().Where("id", this.Id).Value(&file, "sourcemap") + _, err = res.GetDBTable().Where("id", this.Id).Value(&file, "sourcemap") return file, err }