From 29cf434a35d82529f56c085c9cd50858c148d086 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 5 Dec 2006 01:31:45 +0000 Subject: * The determination of the root set should be made by the privileged process, so forward the operation. * Spam the user about GC misconfigurations (NIX-71). * findRoots: skip all roots that are unreadable - the warnings with which we spam the user should be enough. --- src/libstore/remote-store.cc | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) (limited to 'src/libstore/remote-store.cc') diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc index 8dd87d046c2f..6ddbb3e2a260 100644 --- a/src/libstore/remote-store.cc +++ b/src/libstore/remote-store.cc @@ -18,6 +18,23 @@ namespace nix { +Path readStorePath(Source & from) +{ + Path path = readString(from); + assertStorePath(path); + return path; +} + + +PathSet readStorePaths(Source & from) +{ + PathSet paths = readStringSet(from); + for (PathSet::iterator i = paths.begin(); i != paths.end(); ++i) + assertStorePath(*i); + return paths; +} + + RemoteStore::RemoteStore() { string remoteMode = getEnv("NIX_REMOTE"); @@ -179,7 +196,7 @@ void RemoteStore::queryReferences(const Path & path, writeInt(wopQueryReferences, to); writeString(path, to); processStderr(); - PathSet references2 = readStringSet(from); + PathSet references2 = readStorePaths(from); references.insert(references2.begin(), references2.end()); } @@ -190,7 +207,7 @@ void RemoteStore::queryReferrers(const Path & path, writeInt(wopQueryReferrers, to); writeString(path, to); processStderr(); - PathSet referrers2 = readStringSet(from); + PathSet referrers2 = readStorePaths(from); referrers.insert(referrers2.begin(), referrers2.end()); } @@ -207,7 +224,7 @@ Path RemoteStore::addToStore(const Path & _srcPath, bool fixed, writeString(hashAlgo, to); dumpPath(srcPath, to); processStderr(); - Path path = readString(from); + Path path = readStorePath(from); return path; } @@ -221,7 +238,7 @@ Path RemoteStore::addTextToStore(const string & suffix, const string & s, writeStringSet(references, to); processStderr(); - Path path = readString(from); + Path path = readStorePath(from); return path; } @@ -270,6 +287,21 @@ void RemoteStore::syncWithGC() } +Roots RemoteStore::findRoots() +{ + writeInt(wopFindRoots, to); + processStderr(); + unsigned int count = readInt(from); + Roots result; + while (count--) { + Path link = readString(from); + Path target = readStorePath(from); + result[link] = target; + } + return result; +} + + void RemoteStore::processStderr() { unsigned int msg; -- cgit 1.4.1