Skip to content

Commit aeaa38e

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

File tree

1 file changed

+21
-23
lines changed

1 file changed

+21
-23
lines changed

internal/impl/update.go

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -109,31 +109,29 @@ 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 {
122-
// Check if the LocalStorePath is missing for the user's system.
123-
// Since any one user cannot add this field for all systems,
124-
// we'll need to progressively add it to a project's lockfile.
125-
needsLocalStorePath = userSysInfo.LocalStorePath == ""
113+
userSystem, err := nix.System()
114+
if err != nil {
115+
return err
116+
}
117+
118+
// Check if the system info is missing for the user's system.
119+
sysInfo := d.lockfile.Packages[pkg.Raw].Systems[userSystem]
120+
if sysInfo == nil {
121+
d.lockfile.Packages[pkg.Raw] = newEntry
122+
ux.Finfo(d.writer, "Updated system information for %s\n", pkg)
123+
return nil
124+
}
125+
126+
// Check if the LocalStorePath is missing for the user's system.
127+
// Since any one user cannot add this field for all systems,
128+
// we'll need to progressively add it to a project's lockfile.
129+
if sysInfo.LocalStorePath == "" {
130+
// Update the LocalStorePath for the user's system
131+
d.lockfile.Packages[pkg.Raw].Systems[userSystem].LocalStorePath = newEntry.Systems[userSystem].LocalStorePath
132+
ux.Finfo(d.writer, "Updated system information for %s\n", pkg)
133+
return nil
126134
}
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
137135
}
138136

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

0 commit comments

Comments
 (0)