Skip to content

Commit

Permalink
POC: Make nix store delete --recursive best effort
Browse files Browse the repository at this point in the history
Only delete the free paths in the closure rather than trying to delete
everything.
  • Loading branch information
Théophane Hufschmitt committed Jan 3, 2023
1 parent 1534133 commit 0bb351b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/libstore/gc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -765,11 +765,11 @@ void LocalStore::collectGarbage(const GCOptions & options, GCResults & results)

/* Either delete all garbage paths, or just the specified
paths (for gcDeleteSpecific). */
if (options.action == GCOptions::gcDeleteSpecific) {
if (options.action == GCOptions::gcDeleteSpecific || options.action == GCOptions::gcDeleteDead) {

for (auto & i : options.pathsToDelete) {
deleteReferrersClosure(i);
if (!dead.count(i))
if (options.action == GCOptions::gcDeleteSpecific && !dead.count(i))
throw Error(
"Cannot delete path '%1%' since it is still alive. "
"To find out why, use: "
Expand Down
2 changes: 1 addition & 1 deletion src/nix/store-delete.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ using namespace nix;

struct CmdStoreDelete : StorePathsCommand
{
GCOptions options { .action = GCOptions::gcDeleteSpecific };
GCOptions options { .action = GCOptions::gcDeleteDead };

CmdStoreDelete()
{
Expand Down

0 comments on commit 0bb351b

Please sign in to comment.