libstore: asyncify LocalStore::invalidatePath

Change-Id: I9dc8704b183a48c10d5dfd211aac621764e0a483
This commit is contained in:
eldritch horrors
2025-03-05 18:49:45 +01:00
parent 81d5528646
commit c72d057ee3
2 changed files with 9 additions and 5 deletions
+8 -4
View File
@@ -1279,8 +1279,8 @@ try {
/* Invalidate a path. The caller is responsible for checking that
there are no referrers. */
void LocalStore::invalidatePath(DBState & state, const StorePath & path)
{
kj::Promise<Result<void>> LocalStore::invalidatePath(DBState & state, const StorePath & path)
try {
debug("invalidating path '%s'", printStorePath(path));
state.stmts->InvalidatePath.use()(printStorePath(path)).exec();
@@ -1292,6 +1292,10 @@ void LocalStore::invalidatePath(DBState & state, const StorePath & path)
auto state_(Store::state.lock());
state_->pathInfoCache.erase(std::string(path.to_string()));
}
co_return result::success();
} catch (...) {
co_return result::current_exception();
}
const PublicKeys & LocalStore::getPublicKeys()
@@ -1658,7 +1662,7 @@ try {
if (!referrers.empty())
throw PathInUse("cannot delete path '%s' because it is in use by %s",
printStorePath(path), showPaths(referrers));
invalidatePath(*state, path);
TRY_AWAIT(invalidatePath(*state, path));
}
txn.commit();
@@ -1836,7 +1840,7 @@ try {
if (canInvalidate) {
printInfo("path '%s' disappeared, removing from database...", pathS);
auto state = dbPool.get();
invalidatePath(*state, path);
TRY_AWAIT(invalidatePath(*state, path));
} else {
printError("path '%s' disappeared, but it still has valid referrers!", pathS);
if (repair)
+1 -1
View File
@@ -357,7 +357,7 @@ private:
kj::Promise<Result<uint64_t>>
addValidPath(DBState & state, const ValidPathInfo & info, bool checkOutputs = true);
void invalidatePath(DBState & state, const StorePath & path);
kj::Promise<Result<void>> invalidatePath(DBState & state, const StorePath & path);
/**
* Delete a path from the Nix store.