about summary refs log tree commit diff
path: root/src/libstore
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2007-06-12T16·53+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2007-06-12T16·53+0000
commit6d1a1191b053645fa0277830524bf085a7fe0956 (patch)
tree53ad5f6484b612ace6b82224a86cbf95028ea350 /src/libstore
parent9d9e1c5c41023e03ed5069ba6fc17ad3cfeab9f4 (diff)
* Support queryDeriver() in multi-user installations.
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/build.cc2
-rw-r--r--src/libstore/gc.cc2
-rw-r--r--src/libstore/local-store.cc10
-rw-r--r--src/libstore/local-store.hh6
-rw-r--r--src/libstore/remote-store.cc18
-rw-r--r--src/libstore/remote-store.hh2
-rw-r--r--src/libstore/store-api.hh4
-rw-r--r--src/libstore/worker-protocol.hh1
8 files changed, 31 insertions, 14 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index 5c8b31cf6a6b..e300292e96cf 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -1065,7 +1065,7 @@ static string makeValidityRegistration(const PathSet & paths,
     for (PathSet::iterator i = paths.begin(); i != paths.end(); ++i) {
         s += *i + "\n";
 
-        Path deriver = showDerivers ? queryDeriver(noTxn, *i) : "";
+        Path deriver = showDerivers ? store->queryDeriver(*i) : "";
         s += deriver + "\n";
 
         PathSet references;
diff --git a/src/libstore/gc.cc b/src/libstore/gc.cc
index 2ad52d8bf4ea..3699b234402f 100644
--- a/src/libstore/gc.cc
+++ b/src/libstore/gc.cc
@@ -482,7 +482,7 @@ void LocalStore::collectGarbage(GCAction action, const PathSet & pathsToDelete,
             /* Note that the deriver need not be valid (e.g., if we
                previously ran the collector with `gcKeepDerivations'
                turned off). */
-            Path deriver = queryDeriver(noTxn, *i);
+            Path deriver = store->queryDeriver(*i);
             if (deriver != "" && store->isValidPath(deriver))
                 computeFSClosure(deriver, livePaths);
         }
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index cd8bc1a3394f..1165335125b9 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -399,7 +399,7 @@ void setDeriver(const Transaction & txn, const Path & storePath,
 }
 
 
-Path queryDeriver(const Transaction & txn, const Path & storePath)
+static Path queryDeriver(const Transaction & txn, const Path & storePath)
 {
     if (!isRealisablePath(txn, storePath))
         throw Error(format("path `%1%' is not valid") % storePath);
@@ -411,6 +411,12 @@ Path queryDeriver(const Transaction & txn, const Path & storePath)
 }
 
 
+Path LocalStore::queryDeriver(const Path & path)
+{
+    return nix::queryDeriver(noTxn, path);
+}
+
+
 const int substituteVersion = 2;
 
 
@@ -756,7 +762,7 @@ void LocalStore::exportPath(const Path & path, bool sign,
     nix::queryReferences(txn, path, references);
     writeStringSet(references, hashAndWriteSink);
 
-    Path deriver = queryDeriver(txn, path);
+    Path deriver = nix::queryDeriver(txn, path);
     writeString(deriver, hashAndWriteSink);
 
     if (sign) {
diff --git a/src/libstore/local-store.hh b/src/libstore/local-store.hh
index 099be2efcd1a..7c5cd2668405 100644
--- a/src/libstore/local-store.hh
+++ b/src/libstore/local-store.hh
@@ -49,6 +49,8 @@ public:
 
     void queryReferrers(const Path & path, PathSet & referrers);
 
+    Path queryDeriver(const Path & path);
+    
     Path addToStore(const Path & srcPath, bool fixed = false,
         bool recursive = false, string hashAlgo = "",
         PathFilter & filter = defaultPathFilter);
@@ -136,10 +138,6 @@ void setReferences(const Transaction & txn, const Path & path,
 void setDeriver(const Transaction & txn, const Path & path,
     const Path & deriver);
 
-/* Query the deriver of a store path.  Return the empty string if no
-   deriver has been set. */
-Path queryDeriver(const Transaction & txn, const Path & path);
-
 /* Delete a value from the nixStore directory. */
 void deleteFromStore(const Path & path, unsigned long long & bytesFreed);
 
diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc
index 449a4c448f0f..820bf66ad99a 100644
--- a/src/libstore/remote-store.cc
+++ b/src/libstore/remote-store.cc
@@ -212,6 +212,15 @@ void RemoteStore::queryReferrers(const Path & path,
 }
 
 
+Path RemoteStore::queryDeriver(const Path & path)
+{
+    writeInt(wopQueryDeriver, to);
+    writeString(path, to);
+    processStderr();
+    return readStorePath(from);
+}
+
+
 Path RemoteStore::addToStore(const Path & _srcPath, bool fixed,
     bool recursive, string hashAlgo, PathFilter & filter)
 {
@@ -224,8 +233,7 @@ Path RemoteStore::addToStore(const Path & _srcPath, bool fixed,
     writeString(hashAlgo, to);
     dumpPath(srcPath, to, filter);
     processStderr();
-    Path path = readStorePath(from);
-    return path;
+    return readStorePath(from);
 }
 
 
@@ -238,8 +246,7 @@ Path RemoteStore::addTextToStore(const string & suffix, const string & s,
     writeStringSet(references, to);
     
     processStderr();
-    Path path = readStorePath(from);
-    return path;
+    return readStorePath(from);
 }
 
 
@@ -261,8 +268,7 @@ Path RemoteStore::importPath(bool requireSignature, Source & source)
        anyway. */
     
     processStderr(0, &source);
-    Path path = readStorePath(from);
-    return path;
+    return readStorePath(from);
 }
 
 
diff --git a/src/libstore/remote-store.hh b/src/libstore/remote-store.hh
index 19af8c0bed7f..29b4a88f9a4b 100644
--- a/src/libstore/remote-store.hh
+++ b/src/libstore/remote-store.hh
@@ -37,6 +37,8 @@ public:
 
     void queryReferrers(const Path & path, PathSet & referrers);
 
+    Path queryDeriver(const Path & path);
+    
     Path addToStore(const Path & srcPath, bool fixed = false,
         bool recursive = false, string hashAlgo = "",
         PathFilter & filter = defaultPathFilter);
diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh
index 8531eb040496..01b561e9d496 100644
--- a/src/libstore/store-api.hh
+++ b/src/libstore/store-api.hh
@@ -77,6 +77,10 @@ public:
     virtual void queryReferrers(const Path & path,
         PathSet & referrers) = 0;
 
+    /* Query the deriver of a store path.  Return the empty string if
+       no deriver has been set. */
+    virtual Path queryDeriver(const Path & path) = 0;
+
     /* Copy the contents of a path to the store and register the
        validity the resulting path.  The resulting path is returned.
        If `fixed' is true, then the output of a fixed-output
diff --git a/src/libstore/worker-protocol.hh b/src/libstore/worker-protocol.hh
index 0126c8d59db9..4a2e8b6942cf 100644
--- a/src/libstore/worker-protocol.hh
+++ b/src/libstore/worker-protocol.hh
@@ -28,6 +28,7 @@ typedef enum {
     wopCollectGarbage,
     wopExportPath,
     wopImportPath,
+    wopQueryDeriver,
 } WorkerOp;