From 584f8a62de117ade154ec8208d939dc194782936 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Fri, 2 Sep 2016 14:33:58 -0400 Subject: Implement nar-based addToStore for remote-store --- src/libstore/remote-store.cc | 7 ++++++- src/libstore/worker-protocol.hh | 3 ++- src/nix-daemon/nix-daemon.cc | 23 +++++++++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc index 232f62e7ab6d..f03f33fc175c 100644 --- a/src/libstore/remote-store.cc +++ b/src/libstore/remote-store.cc @@ -345,7 +345,12 @@ Path RemoteStore::queryPathFromHashPart(const string & hashPart) void RemoteStore::addToStore(const ValidPathInfo & info, const std::string & nar, bool repair, bool dontCheckSigs) { - throw Error("RemoteStore::addToStore() not implemented"); + auto conn(connections->get()); + conn->to << wopAddToStoreNar + << info.path << info.deriver << printHash(info.narHash) + << info.references << info.registrationTime << info.narSize + << info.ultimate << info.sigs << nar << repair << dontCheckSigs; + conn->processStderr(); } diff --git a/src/libstore/worker-protocol.hh b/src/libstore/worker-protocol.hh index c7f024efe749..2cd246dab5df 100644 --- a/src/libstore/worker-protocol.hh +++ b/src/libstore/worker-protocol.hh @@ -46,7 +46,8 @@ typedef enum { wopVerifyStore = 35, wopBuildDerivation = 36, wopAddSignatures = 37, - wopNarFromPath = 38 + wopNarFromPath = 38, + wopAddToStoreNar = 39 } WorkerOp; diff --git a/src/nix-daemon/nix-daemon.cc b/src/nix-daemon/nix-daemon.cc index 0ef2a6872141..d37bcb3e7e7d 100644 --- a/src/nix-daemon/nix-daemon.cc +++ b/src/nix-daemon/nix-daemon.cc @@ -579,7 +579,30 @@ static void performOp(ref store, bool trusted, unsigned int clientVe case wopNarFromPath: { auto path = readStorePath(*store, from); startWork(); + stopWork(); dumpPath(path, to); + break; + } + + case wopAddToStoreNar: { + ValidPathInfo info; + info.path = readStorePath(*store, from); + info.deriver = readString(from); + if (!info.deriver.empty()) + store->assertStorePath(info.deriver); + info.narHash = parseHash(htSHA256, readString(from)); + info.references = readStorePaths(*store, from); + info.registrationTime = readInt(from); + info.narSize = readLongLong(from); + info.ultimate = readLongLong(from); + info.sigs = readStrings(from); + auto nar = readString(from); + auto repair = readInt(from) ? true : false; + auto dontCheckSigs = readInt(from) ? true : false; + if (!trusted && dontCheckSigs) + dontCheckSigs = false; + startWork(); + store->addToStore(info, nar, repair, dontCheckSigs); stopWork(); break; } -- cgit 1.4.1