about summary refs log tree commit diff
path: root/src/libstore/remote-store.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2016-11-09T17·45+0100
committerEelco Dolstra <edolstra@gmail.com>2016-11-09T17·45+0100
commit21c55ab3b54fc2db30ca53c572d24b38331f508c (patch)
tree9c70dbbdeb47dca6eb723f85631b000298abc09b /src/libstore/remote-store.cc
parenta83b10f84c403d0a38439ce0dd2ce8963cc58af7 (diff)
Implement backwards-compatible RemoteStore::addToStore()
The SSHStore PR adds this functionality to the daemon, but we have to
handle the case where the Nix daemon is 1.11.

Also, don't require signatures for trusted users. This restores 1.11
behaviour.

Fixes https://github.com/NixOS/hydra/issues/398.
Diffstat (limited to 'src/libstore/remote-store.cc')
-rw-r--r--src/libstore/remote-store.cc23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc
index 7a041c6e0a..a4bf7b5870 100644
--- a/src/libstore/remote-store.cc
+++ b/src/libstore/remote-store.cc
@@ -335,7 +335,28 @@ Path RemoteStore::queryPathFromHashPart(const string & hashPart)
 void RemoteStore::addToStore(const ValidPathInfo & info, const ref<std::string> & nar,
     bool repair, bool dontCheckSigs, std::shared_ptr<FSAccessor> accessor)
 {
-    throw Error("RemoteStore::addToStore() not implemented");
+    auto conn(connections->get());
+    conn->to << wopImportPaths;
+
+    StringSink sink;
+    sink << 1 // == path follows
+        ;
+    assert(nar->size() % 8 == 0);
+    sink((unsigned char *) nar->data(), nar->size());
+    sink
+        << exportMagic
+        << info.path
+        << info.references
+        << info.deriver
+        << 0 // == no legacy signature
+        << 0 // == no path follows
+        ;
+
+    StringSource source(*sink.s);
+    conn->processStderr(0, &source);
+
+    auto importedPaths = readStorePaths<PathSet>(*this, conn->from);
+    assert(importedPaths.size() <= 1);
 }