about summary refs log tree commit diff
path: root/src/libstore/misc.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2011-08-31T21·11+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2011-08-31T21·11+0000
commit93227ff65c73e726c4ceef0cdd9439e7a4301417 (patch)
treeba7b60ca132c373913dd4a1c42a900009aeb8a77 /src/libstore/misc.cc
parent5bcdc7e3517e6d679cad1aaba41e4deb76d5a6e7 (diff)
* Eliminate all uses of the global variable ‘store’ from libstore.
  This should also fix:

    nix-instantiate: ./../boost/shared_ptr.hpp:254: T* boost::shared_ptr<T>::operator->() const [with T = nix::StoreAPI]: Assertion `px != 0' failed.

  which was caused by hashDerivationModulo() calling the ‘store’
  object (during store upgrades) before openStore() assigned it.

Diffstat (limited to 'src/libstore/misc.cc')
-rw-r--r--src/libstore/misc.cc30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/libstore/misc.cc b/src/libstore/misc.cc
index 01d6a97ae6..d4bbccd111 100644
--- a/src/libstore/misc.cc
+++ b/src/libstore/misc.cc
@@ -6,15 +6,15 @@
 namespace nix {
 
 
-Derivation derivationFromPath(const Path & drvPath)
+Derivation derivationFromPath(StoreAPI & store, const Path & drvPath)
 {
     assertStorePath(drvPath);
-    store->ensurePath(drvPath);
+    store.ensurePath(drvPath);
     return parseDerivation(readFile(drvPath));
 }
 
 
-void computeFSClosure(const Path & storePath,
+void computeFSClosure(StoreAPI & store, const Path & storePath,
     PathSet & paths, bool flipDirection, bool includeOutputs)
 {
     if (paths.find(storePath) != paths.end()) return;
@@ -22,19 +22,19 @@ void computeFSClosure(const Path & storePath,
 
     PathSet references;
     if (flipDirection)
-        store->queryReferrers(storePath, references);
+        store.queryReferrers(storePath, references);
     else
-        store->queryReferences(storePath, references);
+        store.queryReferences(storePath, references);
 
     if (includeOutputs && isDerivation(storePath)) {
-        PathSet outputs = store->queryDerivationOutputs(storePath);
+        PathSet outputs = store.queryDerivationOutputs(storePath);
         foreach (PathSet::iterator, i, outputs)
-            if (store->isValidPath(*i))
-                computeFSClosure(*i, paths, flipDirection, true);
+            if (store.isValidPath(*i))
+                computeFSClosure(store, *i, paths, flipDirection, true);
     }
 
     foreach (PathSet::iterator, i, references)
-        computeFSClosure(*i, paths, flipDirection, includeOutputs);
+        computeFSClosure(store, *i, paths, flipDirection, includeOutputs);
 }
 
 
@@ -46,7 +46,7 @@ Path findOutput(const Derivation & drv, string id)
 }
 
 
-void queryMissing(const PathSet & targets,
+void queryMissing(StoreAPI & store, const PathSet & targets,
     PathSet & willBuild, PathSet & willSubstitute, PathSet & unknown,
     unsigned long long & downloadSize, unsigned long long & narSize)
 {
@@ -61,15 +61,15 @@ void queryMissing(const PathSet & targets,
         done.insert(p);
 
         if (isDerivation(p)) {
-            if (!store->isValidPath(p)) {
+            if (!store.isValidPath(p)) {
                 unknown.insert(p);
                 continue;
             }
-            Derivation drv = derivationFromPath(p);
+            Derivation drv = derivationFromPath(store, p);
 
             bool mustBuild = false;
             foreach (DerivationOutputs::iterator, i, drv.outputs)
-                if (!store->isValidPath(i->second.path) && !store->hasSubstitutes(i->second.path))
+                if (!store.isValidPath(i->second.path) && !store.hasSubstitutes(i->second.path))
                     mustBuild = true;
 
             if (mustBuild) {
@@ -83,9 +83,9 @@ void queryMissing(const PathSet & targets,
         }
 
         else {
-            if (store->isValidPath(p)) continue;
+            if (store.isValidPath(p)) continue;
             SubstitutablePathInfo info;
-            if (store->querySubstitutablePathInfo(p, info)) {
+            if (store.querySubstitutablePathInfo(p, info)) {
                 willSubstitute.insert(p);
                 downloadSize += info.downloadSize;
                 narSize += info.narSize;