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/libstore/remote-store.cc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/libstore/remote-store.cc') diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc index 6ddbb3e2a2..504eb52329 100644 --- a/src/libstore/remote-store.cc +++ b/src/libstore/remote-store.cc @@ -302,6 +302,27 @@ Roots RemoteStore::findRoots() } +void RemoteStore::collectGarbage(GCAction action, const PathSet & pathsToDelete, + bool ignoreLiveness, PathSet & result, unsigned long long & bytesFreed) +{ + result.clear(); + bytesFreed = 0; + writeInt(wopCollectGarbage, to); + writeInt(action, to); + writeStringSet(pathsToDelete, to); + writeInt(ignoreLiveness, to); + + processStderr(); + + result = readStringSet(from); + + /* Ugh - NAR integers are 64 bits, but read/writeInt() aren't. */ + unsigned int lo = readInt(from); + unsigned int hi = readInt(from); + bytesFreed = (((unsigned long long) hi) << 32) | lo; +} + + void RemoteStore::processStderr() { unsigned int msg; -- cgit 1.4.1