about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-11-30T20·45+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-11-30T20·45+0000
commit02632790713eaabd5250ba04283233c8bc078067 (patch)
tree4848b09faade056cbb76fc28a72b477011eaf4f7
parenta711689368fe0915a2f18ea61fe6e953647d0174 (diff)
* More operations.
-rw-r--r--src/libstore/remote-store.cc23
-rw-r--r--src/libstore/worker-protocol.hh8
-rw-r--r--src/nix-worker/main.cc28
3 files changed, 50 insertions, 9 deletions
diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc
index f59fe8b982fe..99f9589bea7c 100644
--- a/src/libstore/remote-store.cc
+++ b/src/libstore/remote-store.cc
@@ -2,6 +2,7 @@
 #include "util.hh"
 #include "remote-store.hh"
 #include "worker-protocol.hh"
+#include "archive.hh"
 
 #include <iostream>
 #include <unistd.h>
@@ -111,33 +112,45 @@ void RemoteStore::queryReferrers(const Path & storePath,
 
 Path RemoteStore::addToStore(const Path & srcPath)
 {
-    throw Error("not implemented");
+    writeInt(wopAddToStore, to);
+    writeString(baseNameOf(srcPath), to);
+    dumpPath(srcPath, to);
+    Path path = readString(from);
+    return path;
 }
 
 
 Path RemoteStore::addToStoreFixed(bool recursive, string hashAlgo,
     const Path & srcPath)
 {
-    throw Error("not implemented");
+    throw Error("not implemented 4");
 }
 
 
 Path RemoteStore::addTextToStore(const string & suffix, const string & s,
     const PathSet & references)
 {
-    throw Error("not implemented");
+    writeInt(wopAddTextToStore, to);
+    writeString(suffix, to);
+    writeString(s, to);
+    writeInt(references.size(), to);
+    for (PathSet::iterator i = references.begin(); i != references.end(); ++i)
+        writeString(*i, to);
+    
+    Path path = readString(from);
+    return path;
 }
 
 
 void RemoteStore::buildDerivations(const PathSet & drvPaths)
 {
-    throw Error("not implemented");
+    throw Error("not implemented 6");
 }
 
 
 void RemoteStore::ensurePath(const Path & storePath)
 {
-    throw Error("not implemented");
+    throw Error("not implemented 7");
 }
 
 
diff --git a/src/libstore/worker-protocol.hh b/src/libstore/worker-protocol.hh
index 0ba0c374ec92..dd711f3304b1 100644
--- a/src/libstore/worker-protocol.hh
+++ b/src/libstore/worker-protocol.hh
@@ -7,9 +7,11 @@
 
 
 typedef enum {
-    wopQuit = 0,
-    wopIsValidPath = 1,
-    wopQuerySubstitutes = 2,
+    wopQuit,
+    wopIsValidPath,
+    wopQuerySubstitutes,
+    wopAddToStore,
+    wopAddTextToStore,
 } WorkerOp;
 
 
diff --git a/src/nix-worker/main.cc b/src/nix-worker/main.cc
index d6966c2bf5ee..d834e625ef46 100644
--- a/src/nix-worker/main.cc
+++ b/src/nix-worker/main.cc
@@ -3,6 +3,7 @@
 #include "util.hh"
 #include "serialise.hh"
 #include "worker-protocol.hh"
+#include "archive.hh"
 
 using namespace nix;
 
@@ -40,8 +41,33 @@ void processConnection(Source & from, Sink & to)
             break;
         }
 
+        case wopAddToStore: {
+            /* !!! uberquick hack */
+            string baseName = readString(from);
+            Path tmp = createTempDir();
+            Path tmp2 = tmp + "/" + baseName;
+            restorePath(tmp2, from);
+            writeString(store->addToStore(tmp2), to);
+            deletePath(tmp);
+            break;
+        }
+
+        case wopAddTextToStore: {
+            string suffix = readString(from);
+            string s = readString(from);
+            unsigned int refCount = readInt(from);
+            PathSet refs;
+            while (refCount--) {
+                Path ref = readString(from);
+                assertStorePath(ref);
+                refs.insert(ref);
+            }
+            writeString(store->addTextToStore(suffix, s, refs), to);
+            break;
+        }
+
         default:
-            throw Error("invalid operation");
+            throw Error(format("invalid operation %1%") % op);
         }
         
     } while (!quit);