about summary refs log tree commit diff
path: root/src/nix-worker
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-12-01T18·00+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-12-01T18·00+0000
commitb0d8e05be16e9887dbf3edcd6167c7f0b36dee5d (patch)
tree528ed2045ab784848cc70d87c851387d087b6163 /src/nix-worker
parent0565b5f2b35dc153dc98e1e3bd37476aa13ee4f1 (diff)
* More operations.
* addToStore() and friends: don't do a round-trip to the worker if
  we're only interested in the path (i.e., in read-only mode).

Diffstat (limited to 'src/nix-worker')
-rw-r--r--src/nix-worker/main.cc23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/nix-worker/main.cc b/src/nix-worker/main.cc
index 8ac69561f0bf..5d57dd6b62d4 100644
--- a/src/nix-worker/main.cc
+++ b/src/nix-worker/main.cc
@@ -37,11 +37,15 @@ void processConnection(Source & from, Sink & to)
     debug("greeting exchanged");
 
     bool quit = false;
+
+    unsigned int opCount = 0;
     
     do {
         
         WorkerOp op = (WorkerOp) readInt(from);
 
+        opCount++;
+
         switch (op) {
 
         case wopQuit:
@@ -75,13 +79,26 @@ void processConnection(Source & from, Sink & to)
             break;
         }
 
-        case wopAddToStore: {
+        case wopAddToStore:
+        case wopAddToStoreFixed: {
             /* !!! uberquick hack */
             string baseName = readString(from);
+            bool recursive = false;
+            string hashAlgo;
+            if (op == wopAddToStoreFixed) {
+                recursive = readInt(from) == 1;
+                hashAlgo = readString(from);
+            }
+
             Path tmp = createTempDir();
             Path tmp2 = tmp + "/" + baseName;
             restorePath(tmp2, from);
-            writeString(store->addToStore(tmp2), to);
+
+            if (op == wopAddToStoreFixed)
+                writeString(store->addToStoreFixed(recursive, hashAlgo, tmp2), to);
+            else
+                writeString(store->addToStore(tmp2), to);
+            
             deletePath(tmp);
             break;
         }
@@ -113,6 +130,8 @@ void processConnection(Source & from, Sink & to)
         }
         
     } while (!quit);
+
+    printMsg(lvlError, format("%1% worker operations") % opCount);
 }