Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nix
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: c51ee5c0336a
Choose a base ref
...
head repository: NixOS/nix
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 8af4f886e212
Choose a head ref
  • 1 commit
  • 2 files changed
  • 1 contributor

Commits on Jan 5, 2021

  1. Copy the full SHA
    8af4f88 View commit details
Showing with 39 additions and 32 deletions.
  1. +37 −32 src/libstore/local-store.cc
  2. +2 −0 src/libstore/local-store.hh
69 changes: 37 additions & 32 deletions src/libstore/local-store.cc
Original file line number Diff line number Diff line change
@@ -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());

2 changes: 2 additions & 0 deletions src/libstore/local-store.hh
Original file line number Diff line number Diff line change
@@ -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();