diff --git a/lix/libstore/gc.cc b/lix/libstore/gc.cc index 185709c1c..c454b654c 100644 --- a/lix/libstore/gc.cc +++ b/lix/libstore/gc.cc @@ -793,7 +793,7 @@ try { if (!dead.insert(path).second) continue; if (shouldDelete) { try { - invalidatePathChecked(path); + TRY_AWAIT(invalidatePathChecked(path)); deleteFromStore(path.to_string()); referrersCache.erase(path); } catch (PathInUse &) { diff --git a/lix/libstore/local-store.cc b/lix/libstore/local-store.cc index 07bc63072..4dfe03f95 100644 --- a/lix/libstore/local-store.cc +++ b/lix/libstore/local-store.cc @@ -1622,24 +1622,33 @@ std::pair LocalStore::createTempDirInStore() } -void LocalStore::invalidatePathChecked(const StorePath & path) -{ - retrySQLite([&]() { - auto state = dbPool.get(); +kj::Promise> LocalStore::invalidatePathChecked(const StorePath & path) +try { + // NOLINTNEXTLINE(cppcoreguidelines-avoid-capturing-lambda-coroutines) + TRY_AWAIT(retrySQLite([&]() -> kj::Promise> { + try { + auto state = dbPool.get(); - SQLiteTxn txn = state->db.beginTransaction(SQLiteTxnType::Immediate); + SQLiteTxn txn = state->db.beginTransaction(SQLiteTxnType::Immediate); - if (isValidPath_(*state, path)) { - StorePathSet referrers; queryReferrers(*state, path, referrers); - referrers.erase(path); /* ignore self-references */ - if (!referrers.empty()) - throw PathInUse("cannot delete path '%s' because it is in use by %s", - printStorePath(path), showPaths(referrers)); - invalidatePath(*state, path); + if (isValidPath_(*state, path)) { + StorePathSet referrers; queryReferrers(*state, path, referrers); + referrers.erase(path); /* ignore self-references */ + if (!referrers.empty()) + throw PathInUse("cannot delete path '%s' because it is in use by %s", + printStorePath(path), showPaths(referrers)); + invalidatePath(*state, path); + } + + txn.commit(); + co_return result::success(); + } catch (...) { + co_return result::current_exception(); } - - txn.commit(); - }, always_progresses); + })); + co_return result::success(); +} catch (...) { + co_return result::current_exception(); } diff --git a/lix/libstore/local-store.hh b/lix/libstore/local-store.hh index b0cf8c553..b2151ce17 100644 --- a/lix/libstore/local-store.hh +++ b/lix/libstore/local-store.hh @@ -359,7 +359,7 @@ private: /** * Delete a path from the Nix store. */ - void invalidatePathChecked(const StorePath & path); + kj::Promise> invalidatePathChecked(const StorePath & path); kj::Promise> verifyPath(const StorePath & path, const StorePathSet & store, StorePathSet & done, StorePathSet & validPaths, RepairFlag repair, bool & errors);