aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libstore/local-store.cc69
-rw-r--r--src/libstore/local-store.hh2
2 files changed, 39 insertions, 32 deletions
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index c52d4b62a..702e7b136 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -736,54 +736,59 @@ void LocalStore::queryPathInfoUncached(const StorePath & path,
Callback<std::shared_ptr<const ValidPathInfo>> callback) noexcept
{
try {
- callback(retrySQLite<std::shared_ptr<ValidPathInfo>>([&]() {
+ callback(retrySQLite<std::shared_ptr<const ValidPathInfo>>([&]() {
auto state(_state.lock());
+ return queryPathInfoInternal(*state, path);
+ }));
- /* Get the path info. */
- auto useQueryPathInfo(state->stmts->QueryPathInfo.use()(printStorePath(path)));
+ } catch (...) { callback.rethrow(); }
+}
- if (!useQueryPathInfo.next())
- return std::shared_ptr<ValidPathInfo>();
- auto id = useQueryPathInfo.getInt(0);
+std::shared_ptr<const ValidPathInfo> LocalStore::queryPathInfoInternal(State & state, const StorePath & path)
+{
+ /* Get the path info. */
+ auto useQueryPathInfo(state.stmts->QueryPathInfo.use()(printStorePath(path)));
- auto narHash = Hash::dummy;
- try {
- narHash = Hash::parseAnyPrefixed(useQueryPathInfo.getStr(1));
- } catch (BadHash & e) {
- throw Error("invalid-path entry for '%s': %s", printStorePath(path), e.what());
- }
+ if (!useQueryPathInfo.next())
+ return std::shared_ptr<ValidPathInfo>();
- auto info = std::make_shared<ValidPathInfo>(path, narHash);
+ auto id = useQueryPathInfo.getInt(0);
- info->id = id;
+ auto narHash = Hash::dummy;
+ try {
+ narHash = Hash::parseAnyPrefixed(useQueryPathInfo.getStr(1));
+ } catch (BadHash & e) {
+ throw Error("invalid-path entry for '%s': %s", printStorePath(path), e.what());
+ }
- info->registrationTime = useQueryPathInfo.getInt(2);
+ auto info = std::make_shared<ValidPathInfo>(path, narHash);
- auto s = (const char *) sqlite3_column_text(state->stmts->QueryPathInfo, 3);
- if (s) info->deriver = parseStorePath(s);
+ info->id = id;
- /* Note that narSize = NULL yields 0. */
- info->narSize = useQueryPathInfo.getInt(4);
+ info->registrationTime = useQueryPathInfo.getInt(2);
- info->ultimate = useQueryPathInfo.getInt(5) == 1;
+ auto s = (const char *) sqlite3_column_text(state.stmts->QueryPathInfo, 3);
+ if (s) info->deriver = parseStorePath(s);
- s = (const char *) sqlite3_column_text(state->stmts->QueryPathInfo, 6);
- if (s) info->sigs = tokenizeString<StringSet>(s, " ");
+ /* Note that narSize = NULL yields 0. */
+ info->narSize = useQueryPathInfo.getInt(4);
- s = (const char *) sqlite3_column_text(state->stmts->QueryPathInfo, 7);
- if (s) info->ca = parseContentAddressOpt(s);
+ info->ultimate = useQueryPathInfo.getInt(5) == 1;
- /* Get the references. */
- auto useQueryReferences(state->stmts->QueryReferences.use()(info->id));
+ s = (const char *) sqlite3_column_text(state.stmts->QueryPathInfo, 6);
+ if (s) info->sigs = tokenizeString<StringSet>(s, " ");
- while (useQueryReferences.next())
- info->references.insert(parseStorePath(useQueryReferences.getStr(0)));
+ s = (const char *) sqlite3_column_text(state.stmts->QueryPathInfo, 7);
+ if (s) info->ca = parseContentAddressOpt(s);
- return info;
- }));
+ /* Get the references. */
+ auto useQueryReferences(state.stmts->QueryReferences.use()(info->id));
- } catch (...) { callback.rethrow(); }
+ while (useQueryReferences.next())
+ info->references.insert(parseStorePath(useQueryReferences.getStr(0)));
+
+ return info;
}
@@ -1608,7 +1613,7 @@ void LocalStore::addSignatures(const StorePath & storePath, const StringSet & si
SQLiteTxn txn(state->db);
- auto info = std::const_pointer_cast<ValidPathInfo>(std::shared_ptr<const ValidPathInfo>(queryPathInfo(storePath)));
+ auto info = std::const_pointer_cast<ValidPathInfo>(queryPathInfoInternal(*state, storePath));
info->sigs.insert(sigs.begin(), sigs.end());
diff --git a/src/libstore/local-store.hh b/src/libstore/local-store.hh
index ae9497b2e..6d29c5960 100644
--- a/src/libstore/local-store.hh
+++ b/src/libstore/local-store.hh
@@ -235,6 +235,8 @@ private:
void verifyPath(const Path & path, const StringSet & store,
PathSet & done, StorePathSet & validPaths, RepairFlag repair, bool & errors);
+ std::shared_ptr<const ValidPathInfo> queryPathInfoInternal(State & state, const StorePath & path);
+
void updatePathInfo(State & state, const ValidPathInfo & info);
void upgradeStore6();