From 4df6dc28c33d13a7b9784b6fac6812f2425a1497 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sat, 8 Mar 2008 22:48:08 +0000 Subject: [PATCH] * Bug fixes. --- src/libstore/local-store.cc | 4 ++-- src/libstore/local-store.hh | 2 +- src/libstore/store-api.hh | 1 + src/libstore/upgrade-schema.cc | 17 +++++++++-------- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index e70103f47..769b3be7f 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -275,7 +275,7 @@ void LocalStore::registerValidPath(const Path & path, } -void LocalStore::registerValidPath(const ValidPathInfo & info) +void LocalStore::registerValidPath(const ValidPathInfo & info, bool ignoreValidity) { Path infoFile = infoFileFor(info.path); @@ -300,7 +300,7 @@ void LocalStore::registerValidPath(const ValidPathInfo & info) if (!refs.empty()) refs += " "; refs += *i; - if (*i != info.path && !isValidPath(*i)) + if (!ignoreValidity && *i != info.path && !isValidPath(*i)) throw Error(format("cannot register `%1%' as valid, because its reference `%2%' isn't valid") % info.path % *i); diff --git a/src/libstore/local-store.hh b/src/libstore/local-store.hh index 65bec1047..ead49baae 100644 --- a/src/libstore/local-store.hh +++ b/src/libstore/local-store.hh @@ -121,7 +121,7 @@ private: /* Store paths for which the referrers file must be purged. */ PathSet delayedUpdates; - void registerValidPath(const ValidPathInfo & info); + void registerValidPath(const ValidPathInfo & info, bool ignoreValidity = false); ValidPathInfo queryPathInfo(const Path & path); diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh index 0f00b7037..a50dcf645 100644 --- a/src/libstore/store-api.hh +++ b/src/libstore/store-api.hh @@ -267,6 +267,7 @@ struct ValidPathInfo Hash hash; PathSet references; time_t registrationTime; + ValidPathInfo() : registrationTime(0) { } }; typedef list ValidPathInfos; diff --git a/src/libstore/upgrade-schema.cc b/src/libstore/upgrade-schema.cc index 540a51b91..b3d691485 100644 --- a/src/libstore/upgrade-schema.cc +++ b/src/libstore/upgrade-schema.cc @@ -58,19 +58,20 @@ void LocalStore::upgradeStore12() nixDB.enumTable(noTxn, dbValidPaths, paths); for (Paths::iterator i = paths.begin(); i != paths.end(); ++i) { - PathSet references; - Paths references2; - nixDB.queryStrings(noTxn, dbReferences, *i, references2); - references.insert(references2.begin(), references2.end()); + ValidPathInfo info; + info.path = *i; + + Paths references; + nixDB.queryStrings(noTxn, dbReferences, *i, references); + info.references.insert(references.begin(), references.end()); string s; nixDB.queryString(noTxn, dbValidPaths, *i, s); - Hash hash =parseHashField(*i, s); + info.hash = parseHashField(*i, s); - Path deriver; - nixDB.queryString(noTxn, dbDerivers, *i, deriver); + nixDB.queryString(noTxn, dbDerivers, *i, info.deriver); - registerValidPath(*i, hash, references, deriver); + registerValidPath(info, true); std::cerr << "."; }