about summary refs log tree commit diff
path: root/src/nix-worker
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-12-05T02·18+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-12-05T02·18+0000
commita9c4f66cfb1618833cc70ceaf13733730b634193 (patch)
tree47d3b9aab72f561e2e15f18b8ad415153bfd56ef /src/nix-worker
parent29cf434a35d82529f56c085c9cd50858c148d086 (diff)
* Allow unprivileged users to run the garbage collector and to do
  `nix-store --delete'.  But unprivileged users are not allowed to
  ignore liveness.
* `nix-store --delete --ignore-liveness': ignore the runtime roots as
  well.

Diffstat (limited to 'src/nix-worker')
-rw-r--r--src/nix-worker/main.cc22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/nix-worker/main.cc b/src/nix-worker/main.cc
index e772421f39bc..4fa43f643cc9 100644
--- a/src/nix-worker/main.cc
+++ b/src/nix-worker/main.cc
@@ -281,6 +281,28 @@ static void performOp(Source & from, Sink & to, unsigned int op)
         break;
     }
 
+    case wopCollectGarbage: {
+        GCAction action = (GCAction) readInt(from);
+        PathSet pathsToDelete = readStorePaths(from);
+        bool ignoreLiveness = readInt(from);
+
+        PathSet result;
+        unsigned long long bytesFreed;
+        
+        startWork();
+        if (ignoreLiveness)
+            throw Error("you are not allowed to ignore liveness");
+        store->collectGarbage(action, pathsToDelete, ignoreLiveness,
+            result, bytesFreed);
+        stopWork();
+        
+        writeStringSet(result, to);
+        writeInt(bytesFreed & 0xffffffff, to);
+        writeInt(bytesFreed >> 32, to);
+        
+        break;
+    }
+            
     default:
         throw Error(format("invalid operation %1%") % op);
     }