[feat] 完善 PkgVersion GetFilePath GetSourceMapPath
This commit is contained in:
parent
911852d14e
commit
4869409bf7
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user