diff --git a/lix/legacy/nix-store.cc b/lix/legacy/nix-store.cc index 802fd4231..5479eec2b 100644 --- a/lix/legacy/nix-store.cc +++ b/lix/legacy/nix-store.cc @@ -546,7 +546,7 @@ static void opDumpDB(AsyncIoRoot & aio, Strings opFlags, Strings opArgs) ); } } else { - for (auto & i : store->queryAllValidPaths()) + for (auto & i : aio.blockOn(store->queryAllValidPaths())) cout << aio.blockOn(store->makeValidityRegistration({i}, true, true)); } } diff --git a/lix/libcmd/command.cc b/lix/libcmd/command.cc index d3b1f0999..907734821 100644 --- a/lix/libcmd/command.cc +++ b/lix/libcmd/command.cc @@ -159,7 +159,7 @@ void BuiltPathsCommand::run(ref store, Installables && installables) if (installables.size()) throw UsageError("'--all' does not expect arguments"); // XXX: Only uses opaque paths, ignores all the realisations - for (auto & p : store->queryAllValidPaths()) + for (auto & p : aio().blockOn(store->queryAllValidPaths())) paths.emplace_back(BuiltPath::Opaque{p}); } else { paths = Installable::toBuiltPaths( diff --git a/lix/libstore/build/local-derivation-goal.cc b/lix/libstore/build/local-derivation-goal.cc index 57a82fb73..a4e3ffd8f 100644 --- a/lix/libstore/build/local-derivation-goal.cc +++ b/lix/libstore/build/local-derivation-goal.cc @@ -1040,12 +1040,14 @@ struct RestrictedStore : public virtual IndirectRootStore, public virtual GcStor std::string getUri() override { return next->getUri(); } - StorePathSet queryAllValidPaths() override - { + kj::Promise> queryAllValidPaths() override + try { StorePathSet paths; for (auto & p : goal.inputPaths) paths.insert(p); for (auto & p : goal.addedPaths) paths.insert(p); - return paths; + co_return paths; + } catch (...) { + co_return result::current_exception(); } std::shared_ptr queryPathInfoUncached(const StorePath & path) override diff --git a/lix/libstore/daemon.cc b/lix/libstore/daemon.cc index 5a9cadf08..fd6e9b00d 100644 --- a/lix/libstore/daemon.cc +++ b/lix/libstore/daemon.cc @@ -826,7 +826,7 @@ static void performOp(AsyncIoRoot & aio, TunnelLogger * logger, ref store case WorkerProto::Op::QueryAllValidPaths: { logger->startWork(); - auto paths = store->queryAllValidPaths(); + auto paths = aio.blockOn(store->queryAllValidPaths()); logger->stopWork(); to << WorkerProto::write(*store, wconn, paths); break; diff --git a/lix/libstore/local-binary-cache-store.cc b/lix/libstore/local-binary-cache-store.cc index 3df9e7c04..b8b78be7f 100644 --- a/lix/libstore/local-binary-cache-store.cc +++ b/lix/libstore/local-binary-cache-store.cc @@ -83,8 +83,8 @@ protected: } } - StorePathSet queryAllValidPaths() override - { + kj::Promise> queryAllValidPaths() override + try { StorePathSet paths; for (auto & entry : readDirectory(binaryCacheDir)) { @@ -96,7 +96,9 @@ protected: + "-" + MissingName)); } - return paths; + co_return paths; + } catch (...) { + co_return result::current_exception(); } kj::Promise>> isTrustedClient() override diff --git a/lix/libstore/local-store.cc b/lix/libstore/local-store.cc index 117029003..03b648bc4 100644 --- a/lix/libstore/local-store.cc +++ b/lix/libstore/local-store.cc @@ -1023,15 +1023,22 @@ try { } -StorePathSet LocalStore::queryAllValidPaths() -{ - return retrySQLite([&]() { - auto state = dbPool.get(); - auto use(state->stmts->QueryValidPaths.use()); - StorePathSet res; - while (use.next()) res.insert(parseStorePath(use.getStr(0))); - return res; - }, always_progresses); +kj::Promise> LocalStore::queryAllValidPaths() +try { + // NOLINTNEXTLINE(cppcoreguidelines-avoid-capturing-lambda-coroutines) + co_return TRY_AWAIT(retrySQLite([&]() -> kj::Promise> { + try { + auto state = dbPool.get(); + auto use(state->stmts->QueryValidPaths.use()); + StorePathSet res; + while (use.next()) res.insert(parseStorePath(use.getStr(0))); + co_return res; + } catch (...) { + co_return result::current_exception(); + } + })); +} catch (...) { + co_return result::current_exception(); } @@ -1656,7 +1663,7 @@ try { StorePathSet done; - for (auto & i : queryAllValidPaths()) + for (auto & i : TRY_AWAIT(queryAllValidPaths())) TRY_AWAIT(verifyPath(i, storePathsInStoreDir, done, validPaths, repair, errors)); } diff --git a/lix/libstore/local-store.hh b/lix/libstore/local-store.hh index 715da3130..9cf5d29c9 100644 --- a/lix/libstore/local-store.hh +++ b/lix/libstore/local-store.hh @@ -194,7 +194,7 @@ public: kj::Promise> queryValidPaths(const StorePathSet & paths, SubstituteFlag maybeSubstitute = NoSubstitute) override; - StorePathSet queryAllValidPaths() override; + kj::Promise> queryAllValidPaths() override; std::shared_ptr queryPathInfoUncached(const StorePath & path) override; diff --git a/lix/libstore/optimise-store.cc b/lix/libstore/optimise-store.cc index 639cec6d9..21a9f1858 100644 --- a/lix/libstore/optimise-store.cc +++ b/lix/libstore/optimise-store.cc @@ -261,7 +261,7 @@ kj::Promise> LocalStore::optimiseStore(OptimiseStats & stats) try { Activity act(*logger, actOptimiseStore); - auto paths = queryAllValidPaths(); + auto paths = TRY_AWAIT(queryAllValidPaths()); InodeHash inodeHash = loadInodeHash(); act.progress(0, paths.size()); diff --git a/lix/libstore/remote-store.cc b/lix/libstore/remote-store.cc index aa6f1d47a..45151f072 100644 --- a/lix/libstore/remote-store.cc +++ b/lix/libstore/remote-store.cc @@ -228,12 +228,14 @@ try { } -StorePathSet RemoteStore::queryAllValidPaths() -{ +kj::Promise> RemoteStore::queryAllValidPaths() +try { auto conn(getConnection()); conn->to << WorkerProto::Op::QueryAllValidPaths; conn.processStderr(); - return WorkerProto::Serialise::read(*this, *conn); + co_return WorkerProto::Serialise::read(*this, *conn); +} catch (...) { + co_return result::current_exception(); } diff --git a/lix/libstore/remote-store.hh b/lix/libstore/remote-store.hh index 1f23cb366..913184d89 100644 --- a/lix/libstore/remote-store.hh +++ b/lix/libstore/remote-store.hh @@ -55,7 +55,7 @@ public: kj::Promise> queryValidPaths(const StorePathSet & paths, SubstituteFlag maybeSubstitute = NoSubstitute) override; - StorePathSet queryAllValidPaths() override; + kj::Promise> queryAllValidPaths() override; std::shared_ptr queryPathInfoUncached(const StorePath & path) override; diff --git a/lix/libstore/s3-binary-cache-store.cc b/lix/libstore/s3-binary-cache-store.cc index 51c311556..ef8dca0fe 100644 --- a/lix/libstore/s3-binary-cache-store.cc +++ b/lix/libstore/s3-binary-cache-store.cc @@ -487,8 +487,8 @@ struct S3BinaryCacheStoreImpl : public S3BinaryCacheStore throw NoSuchBinaryCacheFile("file '%s' does not exist in binary cache '%s'", path, getUri()); } - StorePathSet queryAllValidPaths() override - { + kj::Promise> queryAllValidPaths() override + try { StorePathSet paths; std::string marker; @@ -518,7 +518,9 @@ struct S3BinaryCacheStoreImpl : public S3BinaryCacheStore marker = res.GetNextMarker(); } while (!marker.empty()); - return paths; + co_return paths; + } catch (...) { + co_return result::current_exception(); } /** diff --git a/lix/libstore/store-api.hh b/lix/libstore/store-api.hh index 87a107a27..e223cdac8 100644 --- a/lix/libstore/store-api.hh +++ b/lix/libstore/store-api.hh @@ -376,8 +376,8 @@ public: * full store path. FIXME: should return a set of * std::variant to get rid of this hack. */ - virtual StorePathSet queryAllValidPaths() - { unsupported("queryAllValidPaths"); } + virtual kj::Promise> queryAllValidPaths() + try { unsupported("queryAllValidPaths"); } catch (...) { return {result::current_exception()}; } constexpr static const char * MissingName = "x";