From 93227ff65c73e726c4ceef0cdd9439e7a4301417 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 31 Aug 2011 21:11:50 +0000 Subject: =?UTF-8?q?*=20Eliminate=20all=20uses=20of=20the=20global=20variab?= =?UTF-8?q?le=20=E2=80=98store=E2=80=99=20from=20libstore.=20=20=20This=20?= =?UTF-8?q?should=20also=20fix:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit nix-instantiate: ./../boost/shared_ptr.hpp:254: T* boost::shared_ptr::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. --- src/libstore/misc.cc | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'src/libstore/misc.cc') diff --git a/src/libstore/misc.cc b/src/libstore/misc.cc index 01d6a97ae..d4bbccd11 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; -- cgit v1.2.3