about summary refs log tree commit diff
path: root/src/libstore
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/remote-store.cc30
-rw-r--r--src/libstore/remote-store.hh2
-rw-r--r--src/libstore/worker-protocol.hh3
3 files changed, 27 insertions, 8 deletions
diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc
index dbeb7cf1227f..1aab90d38c52 100644
--- a/src/libstore/remote-store.cc
+++ b/src/libstore/remote-store.cc
@@ -256,7 +256,13 @@ void RemoteStore::exportPath(const Path & path, bool sign,
 
 Path RemoteStore::importPath(bool requireSignature, Source & source)
 {
-    throw Error("not implemented");
+    writeInt(wopImportPath, to);
+    /* We ignore requireSignature, since the worker forces it to true
+       anyway. */
+    
+    processStderr(0, &source);
+    Path path = readStorePath(from);
+    return path;
 }
 
 
@@ -340,16 +346,28 @@ void RemoteStore::collectGarbage(GCAction action, const PathSet & pathsToDelete,
 }
 
 
-void RemoteStore::processStderr(Sink * sink)
+void RemoteStore::processStderr(Sink * sink, Source * source)
 {
     unsigned int msg;
-    while ((msg = readInt(from)) == STDERR_NEXT || msg == STDERR_DATA) {
-        string s = readString(from);
-        if (msg == STDERR_DATA) {
+    while ((msg = readInt(from)) == STDERR_NEXT
+        || msg == STDERR_READ || msg == STDERR_WRITE) {
+        if (msg == STDERR_WRITE) {
+            string s = readString(from);
             if (!sink) throw Error("no sink");
             (*sink)((const unsigned char *) s.c_str(), s.size());
         }
-        else writeToStderr((const unsigned char *) s.c_str(), s.size());
+        else if (msg == STDERR_READ) {
+            if (!source) throw Error("no source");
+            unsigned int len = readInt(from);
+            unsigned char * buf = new unsigned char[len];
+            AutoDeleteArray<unsigned char> d(buf);
+            (*source)(buf, len);
+            writeString(string((const char *) buf, len), to);
+        }
+        else {
+            string s = readString(from);
+            writeToStderr((const unsigned char *) s.c_str(), s.size());
+        }
     }
     if (msg == STDERR_ERROR)
         throw Error(readString(from));
diff --git a/src/libstore/remote-store.hh b/src/libstore/remote-store.hh
index f57dcbd93866..19af8c0bed7f 100644
--- a/src/libstore/remote-store.hh
+++ b/src/libstore/remote-store.hh
@@ -70,7 +70,7 @@ private:
     FdSource from;
     Pid child;
 
-    void processStderr(Sink * sink = 0);
+    void processStderr(Sink * sink = 0, Source * source = 0);
 
     void forkSlave();
     
diff --git a/src/libstore/worker-protocol.hh b/src/libstore/worker-protocol.hh
index e48fd5fe9708..0126c8d59db9 100644
--- a/src/libstore/worker-protocol.hh
+++ b/src/libstore/worker-protocol.hh
@@ -32,7 +32,8 @@ typedef enum {
 
 
 #define STDERR_NEXT  0x6f6c6d67
-#define STDERR_DATA  0x64617461
+#define STDERR_READ  0x64617461 // data needed from source
+#define STDERR_WRITE 0x64617416 // data for sink
 #define STDERR_LAST  0x616c7473
 #define STDERR_ERROR 0x63787470