about summary refs log tree commit diff
path: root/src/libstore/remote-store.cc
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/libstore/remote-store.cc
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/libstore/remote-store.cc')
-rw-r--r--src/libstore/remote-store.cc25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc
index ce09ddada0..e04bb67139 100644
--- a/src/libstore/remote-store.cc
+++ b/src/libstore/remote-store.cc
@@ -3,6 +3,7 @@
 #include "remote-store.hh"
 #include "worker-protocol.hh"
 #include "archive.hh"
+#include "globals.hh"
 
 #include <iostream>
 #include <unistd.h>
@@ -124,6 +125,12 @@ void RemoteStore::queryReferrers(const Path & path,
 
 Path RemoteStore::addToStore(const Path & srcPath)
 {
+    if (readOnlyMode) {
+        /* No sense in making a round trip, we can just compute the
+           path here. */
+        return computeStorePathForPath(false, false, "", srcPath).first;
+    }
+    
     writeInt(wopAddToStore, to);
     writeString(baseNameOf(srcPath), to);
     dumpPath(srcPath, to);
@@ -135,13 +142,29 @@ Path RemoteStore::addToStore(const Path & srcPath)
 Path RemoteStore::addToStoreFixed(bool recursive, string hashAlgo,
     const Path & srcPath)
 {
-    throw Error("not implemented 6");
+    if (readOnlyMode) {
+        /* No sense in making a round trip, we can just compute the
+           path here. */
+        return computeStorePathForPath(true, recursive, hashAlgo, srcPath).first;
+    }
+    
+    writeInt(wopAddToStoreFixed, to);
+    writeString(baseNameOf(srcPath), to);
+    writeInt(recursive ? 1 : 0, to);
+    writeString(hashAlgo, to);
+    dumpPath(srcPath, to);
+    Path path = readString(from);
+    return path;
 }
 
 
 Path RemoteStore::addTextToStore(const string & suffix, const string & s,
     const PathSet & references)
 {
+    if (readOnlyMode) {
+        return computeStorePathForText(suffix, s);
+    }
+    
     writeInt(wopAddTextToStore, to);
     writeString(suffix, to);
     writeString(s, to);