Skip to content

Commit 68b94d2

Browse files
Théophane Hufschmittbalsoft
authored andcommitted
POC: Make nix store delete --recursive best effort
Only delete the free paths in the closure rather than trying to delete everything.
1 parent 61ddfa1 commit 68b94d2

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/libstore/gc.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -778,11 +778,11 @@ void LocalStore::collectGarbage(const GCOptions & options, GCResults & results)
778778

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

783783
for (auto & i : options.pathsToDelete) {
784784
deleteReferrersClosure(i);
785-
if (!dead.count(i))
785+
if (options.action == GCOptions::gcDeleteSpecific && !dead.count(i))
786786
throw Error(
787787
"Cannot delete path '%1%' since it is still alive. "
788788
"To find out why, use: "

src/nix/store-delete.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ using namespace nix;
99

1010
struct CmdStoreDelete : StorePathsCommand
1111
{
12-
GCOptions options { .action = GCOptions::gcDeleteSpecific };
12+
GCOptions options { .action = GCOptions::gcDeleteDead };
1313

1414
CmdStoreDelete()
1515
{

0 commit comments

Comments
 (0)