about summary refs log tree commit diff
path: root/src/nix-store
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2005-12-23T21·36+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2005-12-23T21·36+0000
commitf96d2dea266760e5587356e72d1cadaace5f7d5b (patch)
treeb335134787eb543588df53453bd19fdc1d080c84 /src/nix-store
parent4b9e7f59ca14c3de7b0cfdaebca98fa2639bbbf9 (diff)
* Added a flag `--ignore-liveness' to `nix-store --delete'. It
  deletes a path even if it is reachable from a root.  However, it
  won't delete a path that still has referrers (since that would
  violate store invariants).

  Don't try this at home.  It's a useful hack for recovering from
  certain situations in a somewhat clean way (e.g., holes in closures
  due to disk corruption).

Diffstat (limited to 'src/nix-store')
-rw-r--r--src/nix-store/main.cc11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/nix-store/main.cc b/src/nix-store/main.cc
index 6f1fab13de36..88e6720c020a 100644
--- a/src/nix-store/main.cc
+++ b/src/nix-store/main.cc
@@ -518,7 +518,7 @@ static void opGC(Strings opFlags, Strings opArgs)
 
     PathSet result;
     PrintFreed freed(action == gcDeleteDead);
-    collectGarbage(action, PathSet(), result, freed.bytesFreed);
+    collectGarbage(action, PathSet(), false, result, freed.bytesFreed);
 
     if (action != gcDeleteDead) {
         for (PathSet::iterator i = result.begin(); i != result.end(); ++i)
@@ -532,7 +532,12 @@ static void opGC(Strings opFlags, Strings opArgs)
    roots). */
 static void opDelete(Strings opFlags, Strings opArgs)
 {
-    if (!opFlags.empty()) throw UsageError("unknown flag");
+    bool ignoreLiveness;
+    
+    for (Strings::iterator i = opFlags.begin();
+         i != opFlags.end(); ++i)
+        if (*i == "--ignore-liveness") ignoreLiveness = true;
+        else throw UsageError(format("unknown flag `%1%'") % *i);
 
     PathSet pathsToDelete;
     for (Strings::iterator i = opArgs.begin();
@@ -541,7 +546,7 @@ static void opDelete(Strings opFlags, Strings opArgs)
     
     PathSet dummy;
     PrintFreed freed(true);
-    collectGarbage(gcDeleteSpecific, pathsToDelete,
+    collectGarbage(gcDeleteSpecific, pathsToDelete, ignoreLiveness,
         dummy, freed.bytesFreed);
 }