Skip to content

Commit fc414f7

Browse files
committed
lucille: rewrite for clarity
1 parent a735e64 commit fc414f7

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

internal/impl/update.go

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -109,31 +109,30 @@ func (d *Devbox) updateDevboxPackage(
109109
}
110110

111111
// Check if the package's system info is missing, or not complete.
112-
userSystem, err := nix.System()
113-
if err != nil {
114-
return err
115-
}
116-
var needsSysInfo bool
117-
var needsLocalStorePath bool
118112
if featureflag.RemoveNixpkgs.Enabled() {
119-
userSysInfo := d.lockfile.Packages[pkg.Raw].Systems[userSystem]
120-
needsSysInfo = userSysInfo == nil
121-
if !needsSysInfo {
113+
userSystem, err := nix.System()
114+
if err != nil {
115+
return err
116+
}
117+
var caStorePath string
118+
sysInfo := d.lockfile.Packages[pkg.Raw].Systems[userSystem]
119+
if sysInfo != nil {
122120
// Check if the LocalStorePath is missing for the user's system.
123-
// Since any one user cannot add this field for all systems,
121+
// Since any one user cannot add this field for all systems,
124122
// we'll need to progressively add it to a project's lockfile.
125-
needsLocalStorePath = userSysInfo.LocalStorePath == ""
123+
caStorePath = sysInfo.LocalStorePath
124+
}
125+
126+
if sysInfo == nil {
127+
d.lockfile.Packages[pkg.Raw] = newEntry
128+
ux.Finfo(d.writer, "Updated system information for %s\n", pkg)
129+
return nil
130+
} else if caStorePath == "" {
131+
// Update the LocalStorePath for the user's system
132+
d.lockfile.Packages[pkg.Raw].Systems[userSystem].LocalStorePath = newEntry.Systems[userSystem].LocalStorePath
133+
ux.Finfo(d.writer, "Updated system information for %s\n", pkg)
134+
return nil
126135
}
127-
}
128-
if needsSysInfo {
129-
d.lockfile.Packages[pkg.Raw] = newEntry
130-
ux.Finfo(d.writer, "Updated system information for %s\n", pkg)
131-
return nil
132-
} else if needsLocalStorePath {
133-
// Update the LocalStorePath for the user's system
134-
d.lockfile.Packages[pkg.Raw].Systems[userSystem].LocalStorePath = newEntry.Systems[userSystem].LocalStorePath
135-
ux.Finfo(d.writer, "Updated system information for %s\n", pkg)
136-
return nil
137136
}
138137

139138
ux.Finfo(d.writer, "Already up-to-date %s %s\n", pkg, existing.Version)

0 commit comments

Comments
 (0)