diff --git a/lix/libstore/binary-cache-store.cc b/lix/libstore/binary-cache-store.cc index 8e802a1d8..e027c092c 100644 --- a/lix/libstore/binary-cache-store.cc +++ b/lix/libstore/binary-cache-store.cc @@ -328,12 +328,14 @@ try { co_return result::current_exception(); } -bool BinaryCacheStore::isValidPathUncached(const StorePath & storePath) -{ +kj::Promise> BinaryCacheStore::isValidPathUncached(const StorePath & storePath) +try { // FIXME: this only checks whether a .narinfo with a matching hash // part exists. So ‘f4kb...-foo’ matches ‘f4kb...-bar’, even // though they shouldn't. Not easily fixed. - return fileExists(narInfoFileFor(storePath)); + co_return fileExists(narInfoFileFor(storePath)); +} catch (...) { + co_return result::current_exception(); } kj::Promise>> diff --git a/lix/libstore/binary-cache-store.hh b/lix/libstore/binary-cache-store.hh index 8418baf1e..18399255f 100644 --- a/lix/libstore/binary-cache-store.hh +++ b/lix/libstore/binary-cache-store.hh @@ -109,7 +109,7 @@ private: public: - bool isValidPathUncached(const StorePath & path) override; + kj::Promise> isValidPathUncached(const StorePath & path) override; std::shared_ptr queryPathInfoUncached(const StorePath & path) override; diff --git a/lix/libstore/local-store.cc b/lix/libstore/local-store.cc index 16913f67b..03e1ec81b 100644 --- a/lix/libstore/local-store.cc +++ b/lix/libstore/local-store.cc @@ -1004,12 +1004,19 @@ bool LocalStore::isValidPath_(DBState & state, const StorePath & path) } -bool LocalStore::isValidPathUncached(const StorePath & path) -{ - return retrySQLite([&]() { - auto state = dbPool.get(); - return isValidPath_(*state, path); - }, always_progresses); +kj::Promise> LocalStore::isValidPathUncached(const StorePath & path) +try { + // NOLINTNEXTLINE(cppcoreguidelines-avoid-capturing-lambda-coroutines) + co_return TRY_AWAIT(retrySQLite([&]() -> kj::Promise> { + try { + auto state = dbPool.get(); + co_return isValidPath_(*state, path); + } catch (...) { + co_return result::current_exception(); + } + })); +} catch (...) { + co_return result::current_exception(); } diff --git a/lix/libstore/local-store.hh b/lix/libstore/local-store.hh index 3726a5464..aa0b41ed7 100644 --- a/lix/libstore/local-store.hh +++ b/lix/libstore/local-store.hh @@ -189,7 +189,7 @@ public: std::string getUri() override; - bool isValidPathUncached(const StorePath & path) override; + kj::Promise> isValidPathUncached(const StorePath & path) override; kj::Promise> queryValidPaths(const StorePathSet & paths, SubstituteFlag maybeSubstitute = NoSubstitute) override; diff --git a/lix/libstore/remote-store.cc b/lix/libstore/remote-store.cc index 8b2c138fc..7e1597963 100644 --- a/lix/libstore/remote-store.cc +++ b/lix/libstore/remote-store.cc @@ -203,12 +203,14 @@ try { co_return result::current_exception(); } -bool RemoteStore::isValidPathUncached(const StorePath & path) -{ +kj::Promise> RemoteStore::isValidPathUncached(const StorePath & path) +try { auto conn(getConnection()); conn->to << WorkerProto::Op::IsValidPath << printStorePath(path); conn.processStderr(); - return readInt(conn->from); + co_return readInt(conn->from); +} catch (...) { + co_return result::current_exception(); } diff --git a/lix/libstore/remote-store.hh b/lix/libstore/remote-store.hh index a095dd5cc..4d628111c 100644 --- a/lix/libstore/remote-store.hh +++ b/lix/libstore/remote-store.hh @@ -50,7 +50,7 @@ public: /* Implementations of abstract store API methods. */ - bool isValidPathUncached(const StorePath & path) override; + kj::Promise> isValidPathUncached(const StorePath & path) override; kj::Promise> queryValidPaths(const StorePathSet & paths, SubstituteFlag maybeSubstitute = NoSubstitute) override; diff --git a/lix/libstore/s3-binary-cache-store.cc b/lix/libstore/s3-binary-cache-store.cc index ef8dca0fe..b452b87f5 100644 --- a/lix/libstore/s3-binary-cache-store.cc +++ b/lix/libstore/s3-binary-cache-store.cc @@ -313,14 +313,14 @@ struct S3BinaryCacheStoreImpl : public S3BinaryCacheStore fetches the .narinfo file, rather than first checking for its existence via a HEAD request. Since .narinfos are small, doing a GET is unlikely to be slower than HEAD. */ - bool isValidPathUncached(const StorePath & storePath) override - { - try { - queryPathInfo(storePath); - return true; - } catch (InvalidPath & e) { - return false; - } + kj::Promise> isValidPathUncached(const StorePath & storePath) override + try { + queryPathInfo(storePath); + co_return true; + } catch (InvalidPath & e) { + co_return false; + } catch (...) { + co_return result::current_exception(); } bool fileExists(const std::string & path) override diff --git a/lix/libstore/store-api.cc b/lix/libstore/store-api.cc index f4ebb3b30..11ef9af2d 100644 --- a/lix/libstore/store-api.cc +++ b/lix/libstore/store-api.cc @@ -655,7 +655,7 @@ try { } } - bool valid = isValidPathUncached(storePath); + bool valid = TRY_AWAIT(isValidPathUncached(storePath)); if (diskCache && !valid) // FIXME: handle valid = true case. @@ -669,14 +669,14 @@ try { /* Default implementation for stores that only implement queryPathInfoUncached(). */ -bool Store::isValidPathUncached(const StorePath & path) -{ - try { - queryPathInfo(path); - return true; - } catch (InvalidPath &) { - return false; - } +kj::Promise> Store::isValidPathUncached(const StorePath & path) +try { + queryPathInfo(path); + co_return true; +} catch (InvalidPath &) { + co_return false; +} catch (...) { + co_return result::current_exception(); } diff --git a/lix/libstore/store-api.hh b/lix/libstore/store-api.hh index 829070067..b0c1d17dd 100644 --- a/lix/libstore/store-api.hh +++ b/lix/libstore/store-api.hh @@ -350,7 +350,7 @@ public: protected: - virtual bool isValidPathUncached(const StorePath & path); + virtual kj::Promise> isValidPathUncached(const StorePath & path); public: