Skip to content

Commit 538363b

Browse files
committed
[perf] in syncPackagesToProfile, only removeExtraItemsFromProfile is mode is not install
1 parent 85a4b9a commit 538363b

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed
45.1 KB
Binary file not shown.

internal/impl/packages.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,8 @@ func (d *Devbox) profilePath() (string, error) {
304304
return absPath, errors.WithStack(os.MkdirAll(filepath.Dir(absPath), 0o755))
305305
}
306306

307-
// syncPackagesToProfile ensures that all packages in devbox.json exist in the nix profile,
308-
// and no more.
307+
// syncPackagesToProfile can ensure that all packages in devbox.json exist in the nix profile,
308+
// and no more. However, it may skip some steps depending on the `mode`.
309309
func (d *Devbox) syncPackagesToProfile(ctx context.Context, mode installMode) error {
310310
defer debug.FunctionTimer().End()
311311
defer trace.StartRegion(ctx, "syncPackagesToProfile").End()
@@ -333,9 +333,12 @@ func (d *Devbox) syncPackagesToProfile(ctx context.Context, mode installMode) er
333333
}
334334

335335
// Second, remove any packages from the nix-profile that are not in the config
336-
itemsToKeep, err := d.removeExtraItemsFromProfile(ctx, profileDir, profileItems, packages)
337-
if err != nil {
338-
return err
336+
itemsToKeep := profileItems
337+
if mode != install {
338+
itemsToKeep, err = d.removeExtraItemsFromProfile(ctx, profileDir, profileItems, packages)
339+
if err != nil {
340+
return err
341+
}
339342
}
340343

341344
// we are done if mode is uninstall

trace.out

49.2 KB
Binary file not shown.

0 commit comments

Comments
 (0)