From 9d52d0db790579fa42a2025a6bb90b556437f207 Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Tue, 4 Mar 2025 23:08:34 +0100 Subject: [PATCH] libstore: asyncify LocalStore::addValidPath Change-Id: Iada9f7647b6913d267b061421d7b3d7b1bed8343 --- lix/libstore/local-store.cc | 10 ++++++---- lix/libstore/local-store.hh | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lix/libstore/local-store.cc b/lix/libstore/local-store.cc index 81b87997e..53dcca1f1 100644 --- a/lix/libstore/local-store.cc +++ b/lix/libstore/local-store.cc @@ -863,9 +863,9 @@ void LocalStore::cacheDrvOutputMapping( } -uint64_t LocalStore::addValidPath(DBState & state, +kj::Promise> LocalStore::addValidPath(DBState & state, const ValidPathInfo & info, bool checkOutputs) -{ +try { if (info.ca.has_value() && !info.isContentAddressed(*this)) throw Error("cannot add path '%s' to the Nix store because it claims to be content-addressed but isn't", printStorePath(info.path)); @@ -910,7 +910,9 @@ uint64_t LocalStore::addValidPath(DBState & state, PathInfoCacheValue{ .value = std::make_shared(info) }); } - return id; + co_return id; +} catch (...) { + co_return result::current_exception(); } @@ -1210,7 +1212,7 @@ try { if (isValidPath_(*state, i.path)) updatePathInfo(*state, i); else - addValidPath(*state, i, false); + TRY_AWAIT(addValidPath(*state, i, false)); paths.insert(i.path); } diff --git a/lix/libstore/local-store.hh b/lix/libstore/local-store.hh index 165554fa4..3726a5464 100644 --- a/lix/libstore/local-store.hh +++ b/lix/libstore/local-store.hh @@ -353,7 +353,8 @@ private: uint64_t queryValidPathId(DBState & state, const StorePath & path); - uint64_t addValidPath(DBState & state, const ValidPathInfo & info, bool checkOutputs = true); + kj::Promise> + addValidPath(DBState & state, const ValidPathInfo & info, bool checkOutputs = true); void invalidatePath(DBState & state, const StorePath & path);