From a9c4f66cfb1618833cc70ceaf13733730b634193 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 5 Dec 2006 02:18:46 +0000 Subject: * 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. --- src/nix-worker/main.cc | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/nix-worker/main.cc') 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); } -- cgit 1.4.1