MCPcopy Create free account
hub / github.com/HashLoad/boss / LoadPackageLock

Function LoadPackageLock

models/lock.go:54–82  ·  view source on GitHub ↗
(parentPackage *Package)

Source from the content-addressed store, hash-verified

52}
53
54func LoadPackageLock(parentPackage *Package) PackageLock {
55 removeOld(parentPackage)
56 packageLockPath := filepath.Join(filepath.Dir(parentPackage.fileName), consts.FilePackageLock)
57 if fileBytes, err := ioutil.ReadFile(packageLockPath); err != nil {
58 hash := md5.New()
59 if _, err := io.WriteString(hash, parentPackage.Name); err != nil {
60 msg.Warn("Failed on write machine id to hash")
61 }
62
63 return PackageLock{
64 fileName: packageLockPath,
65 Updated: time.Now(),
66 Hash: hex.EncodeToString(hash.Sum(nil)),
67
68 Installed: map[string]LockedDependency{},
69 }
70 } else {
71 lockfile := PackageLock{
72 fileName: packageLockPath,
73 Updated: time.Now(),
74 Installed: map[string]LockedDependency{},
75 }
76
77 if err := json.Unmarshal(fileBytes, &lockfile); err != nil {
78 utils.HandleError(err)
79 }
80 return lockfile
81 }
82}
83
84func (p PackageLock) Save() {
85 marshal, err := json.MarshalIndent(&p, "", "\t")

Callers 2

getNewFunction · 0.85
LoadPackageFunction · 0.85

Calls 4

WarnFunction · 0.92
HandleErrorFunction · 0.92
removeOldFunction · 0.85
NewMethod · 0.80

Tested by

no test coverage detected