parent
c51ee5c033
commit
8af4f886e2
2 changed files with 52 additions and 45 deletions
|
@ -736,57 +736,62 @@ void LocalStore::queryPathInfoUncached(const StorePath & path,
|
||||||
Callback<std::shared_ptr<const ValidPathInfo>> callback) noexcept
|
Callback<std::shared_ptr<const ValidPathInfo>> callback) noexcept
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
callback(retrySQLite<std::shared_ptr<ValidPathInfo>>([&]() {
|
callback(retrySQLite<std::shared_ptr<const ValidPathInfo>>([&]() {
|
||||||
auto state(_state.lock());
|
auto state(_state.lock());
|
||||||
|
return queryPathInfoInternal(*state, path);
|
||||||
/* Get the path info. */
|
|
||||||
auto useQueryPathInfo(state->stmts->QueryPathInfo.use()(printStorePath(path)));
|
|
||||||
|
|
||||||
if (!useQueryPathInfo.next())
|
|
||||||
return std::shared_ptr<ValidPathInfo>();
|
|
||||||
|
|
||||||
auto id = useQueryPathInfo.getInt(0);
|
|
||||||
|
|
||||||
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());
|
|
||||||
}
|
|
||||||
|
|
||||||
auto info = std::make_shared<ValidPathInfo>(path, narHash);
|
|
||||||
|
|
||||||
info->id = id;
|
|
||||||
|
|
||||||
info->registrationTime = useQueryPathInfo.getInt(2);
|
|
||||||
|
|
||||||
auto s = (const char *) sqlite3_column_text(state->stmts->QueryPathInfo, 3);
|
|
||||||
if (s) info->deriver = parseStorePath(s);
|
|
||||||
|
|
||||||
/* Note that narSize = NULL yields 0. */
|
|
||||||
info->narSize = useQueryPathInfo.getInt(4);
|
|
||||||
|
|
||||||
info->ultimate = useQueryPathInfo.getInt(5) == 1;
|
|
||||||
|
|
||||||
s = (const char *) sqlite3_column_text(state->stmts->QueryPathInfo, 6);
|
|
||||||
if (s) info->sigs = tokenizeString<StringSet>(s, " ");
|
|
||||||
|
|
||||||
s = (const char *) sqlite3_column_text(state->stmts->QueryPathInfo, 7);
|
|
||||||
if (s) info->ca = parseContentAddressOpt(s);
|
|
||||||
|
|
||||||
/* Get the references. */
|
|
||||||
auto useQueryReferences(state->stmts->QueryReferences.use()(info->id));
|
|
||||||
|
|
||||||
while (useQueryReferences.next())
|
|
||||||
info->references.insert(parseStorePath(useQueryReferences.getStr(0)));
|
|
||||||
|
|
||||||
return info;
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
} catch (...) { callback.rethrow(); }
|
} catch (...) { callback.rethrow(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::shared_ptr<const ValidPathInfo> LocalStore::queryPathInfoInternal(State & state, const StorePath & path)
|
||||||
|
{
|
||||||
|
/* Get the path info. */
|
||||||
|
auto useQueryPathInfo(state.stmts->QueryPathInfo.use()(printStorePath(path)));
|
||||||
|
|
||||||
|
if (!useQueryPathInfo.next())
|
||||||
|
return std::shared_ptr<ValidPathInfo>();
|
||||||
|
|
||||||
|
auto id = useQueryPathInfo.getInt(0);
|
||||||
|
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
|
auto info = std::make_shared<ValidPathInfo>(path, narHash);
|
||||||
|
|
||||||
|
info->id = id;
|
||||||
|
|
||||||
|
info->registrationTime = useQueryPathInfo.getInt(2);
|
||||||
|
|
||||||
|
auto s = (const char *) sqlite3_column_text(state.stmts->QueryPathInfo, 3);
|
||||||
|
if (s) info->deriver = parseStorePath(s);
|
||||||
|
|
||||||
|
/* Note that narSize = NULL yields 0. */
|
||||||
|
info->narSize = useQueryPathInfo.getInt(4);
|
||||||
|
|
||||||
|
info->ultimate = useQueryPathInfo.getInt(5) == 1;
|
||||||
|
|
||||||
|
s = (const char *) sqlite3_column_text(state.stmts->QueryPathInfo, 6);
|
||||||
|
if (s) info->sigs = tokenizeString<StringSet>(s, " ");
|
||||||
|
|
||||||
|
s = (const char *) sqlite3_column_text(state.stmts->QueryPathInfo, 7);
|
||||||
|
if (s) info->ca = parseContentAddressOpt(s);
|
||||||
|
|
||||||
|
/* Get the references. */
|
||||||
|
auto useQueryReferences(state.stmts->QueryReferences.use()(info->id));
|
||||||
|
|
||||||
|
while (useQueryReferences.next())
|
||||||
|
info->references.insert(parseStorePath(useQueryReferences.getStr(0)));
|
||||||
|
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Update path info in the database. */
|
/* Update path info in the database. */
|
||||||
void LocalStore::updatePathInfo(State & state, const ValidPathInfo & info)
|
void LocalStore::updatePathInfo(State & state, const ValidPathInfo & info)
|
||||||
{
|
{
|
||||||
|
@ -1608,7 +1613,7 @@ void LocalStore::addSignatures(const StorePath & storePath, const StringSet & si
|
||||||
|
|
||||||
SQLiteTxn txn(state->db);
|
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());
|
info->sigs.insert(sigs.begin(), sigs.end());
|
||||||
|
|
||||||
|
|
|
@ -235,6 +235,8 @@ private:
|
||||||
void verifyPath(const Path & path, const StringSet & store,
|
void verifyPath(const Path & path, const StringSet & store,
|
||||||
PathSet & done, StorePathSet & validPaths, RepairFlag repair, bool & errors);
|
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 updatePathInfo(State & state, const ValidPathInfo & info);
|
||||||
|
|
||||||
void upgradeStore6();
|
void upgradeStore6();
|
||||||
|
|
Loading…
Reference in a new issue