about summary refs log tree commit diff
path: root/src/nix-worker/main.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-11-30T22·43+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-11-30T22·43+0000
commit0565b5f2b35dc153dc98e1e3bd37476aa13ee4f1 (patch)
treea370db3e93b6e07f044fc436092c9d082da9c8be /src/nix-worker/main.cc
parentaac547a8b3f481fda48cc1fe1082ce4c32be0e03 (diff)
* More remote operations.
* Added new operation hasSubstitutes(), which is more efficient than
  querySubstitutes().size() > 0.

Diffstat (limited to 'src/nix-worker/main.cc')
-rw-r--r--src/nix-worker/main.cc60
1 files changed, 51 insertions, 9 deletions
diff --git a/src/nix-worker/main.cc b/src/nix-worker/main.cc
index d834e625ef..8ac69561f0 100644
--- a/src/nix-worker/main.cc
+++ b/src/nix-worker/main.cc
@@ -8,6 +8,23 @@
 using namespace nix;
 
 
+Path readStorePath(Source & from)
+{
+    Path path = readString(from);
+    assertStorePath(path);
+    return path;
+}
+
+
+PathSet readStorePaths(Source & from)
+{
+    PathSet paths = readStringSet(from);
+    for (PathSet::iterator i = paths.begin(); i != paths.end(); ++i)
+        assertStorePath(*i);
+    return paths;
+}
+
+
 void processConnection(Source & from, Sink & to)
 {
     store = boost::shared_ptr<StoreAPI>(new LocalStore(true));
@@ -35,12 +52,29 @@ void processConnection(Source & from, Sink & to)
             break;
 
         case wopIsValidPath: {
-            Path path = readString(from);
-            assertStorePath(path);
+            Path path = readStorePath(from);
             writeInt(store->isValidPath(path), to);
             break;
         }
 
+        case wopHasSubstitutes: {
+            Path path = readStorePath(from);
+            writeInt(store->hasSubstitutes(path), to);
+            break;
+        }
+
+        case wopQueryReferences:
+        case wopQueryReferrers: {
+            Path path = readStorePath(from);
+            PathSet paths;
+            if (op == wopQueryReferences)
+                store->queryReferences(path, paths);
+            else
+                store->queryReferrers(path, paths);
+            writeStringSet(paths, to);
+            break;
+        }
+
         case wopAddToStore: {
             /* !!! uberquick hack */
             string baseName = readString(from);
@@ -55,17 +89,25 @@ void processConnection(Source & from, Sink & to)
         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);
-            }
+            PathSet refs = readStorePaths(from);
             writeString(store->addTextToStore(suffix, s, refs), to);
             break;
         }
 
+        case wopBuildDerivations: {
+            PathSet drvs = readStorePaths(from);
+            store->buildDerivations(drvs);
+            writeInt(1, to);
+            break;
+        }
+
+        case wopEnsurePath: {
+            Path path = readStorePath(from);
+            store->ensurePath(path);
+            writeInt(1, to);
+            break;
+        }
+
         default:
             throw Error(format("invalid operation %1%") % op);
         }