libstore: asyncify Store::queryAllValidPaths
Change-Id: I2c38669fd061d1b34a659db4c821be8a69a6835c
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ void BuiltPathsCommand::run(ref<Store> 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(
|
||||
|
||||
@@ -1040,12 +1040,14 @@ struct RestrictedStore : public virtual IndirectRootStore, public virtual GcStor
|
||||
std::string getUri() override
|
||||
{ return next->getUri(); }
|
||||
|
||||
StorePathSet queryAllValidPaths() override
|
||||
{
|
||||
kj::Promise<Result<StorePathSet>> 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<const ValidPathInfo> queryPathInfoUncached(const StorePath & path) override
|
||||
|
||||
@@ -826,7 +826,7 @@ static void performOp(AsyncIoRoot & aio, TunnelLogger * logger, ref<Store> 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;
|
||||
|
||||
@@ -83,8 +83,8 @@ protected:
|
||||
}
|
||||
}
|
||||
|
||||
StorePathSet queryAllValidPaths() override
|
||||
{
|
||||
kj::Promise<Result<StorePathSet>> 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<Result<std::optional<TrustedFlag>>> isTrustedClient() override
|
||||
|
||||
+17
-10
@@ -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<Result<StorePathSet>> LocalStore::queryAllValidPaths()
|
||||
try {
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-capturing-lambda-coroutines)
|
||||
co_return TRY_AWAIT(retrySQLite([&]() -> kj::Promise<Result<StorePathSet>> {
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
@@ -194,7 +194,7 @@ public:
|
||||
kj::Promise<Result<StorePathSet>> queryValidPaths(const StorePathSet & paths,
|
||||
SubstituteFlag maybeSubstitute = NoSubstitute) override;
|
||||
|
||||
StorePathSet queryAllValidPaths() override;
|
||||
kj::Promise<Result<StorePathSet>> queryAllValidPaths() override;
|
||||
|
||||
std::shared_ptr<const ValidPathInfo> queryPathInfoUncached(const StorePath & path) override;
|
||||
|
||||
|
||||
@@ -261,7 +261,7 @@ kj::Promise<Result<void>> 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());
|
||||
|
||||
@@ -228,12 +228,14 @@ try {
|
||||
}
|
||||
|
||||
|
||||
StorePathSet RemoteStore::queryAllValidPaths()
|
||||
{
|
||||
kj::Promise<Result<StorePathSet>> RemoteStore::queryAllValidPaths()
|
||||
try {
|
||||
auto conn(getConnection());
|
||||
conn->to << WorkerProto::Op::QueryAllValidPaths;
|
||||
conn.processStderr();
|
||||
return WorkerProto::Serialise<StorePathSet>::read(*this, *conn);
|
||||
co_return WorkerProto::Serialise<StorePathSet>::read(*this, *conn);
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
kj::Promise<Result<StorePathSet>> queryValidPaths(const StorePathSet & paths,
|
||||
SubstituteFlag maybeSubstitute = NoSubstitute) override;
|
||||
|
||||
StorePathSet queryAllValidPaths() override;
|
||||
kj::Promise<Result<StorePathSet>> queryAllValidPaths() override;
|
||||
|
||||
std::shared_ptr<const ValidPathInfo> queryPathInfoUncached(const StorePath & path) override;
|
||||
|
||||
|
||||
@@ -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<Result<StorePathSet>> 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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -376,8 +376,8 @@ public:
|
||||
* full store path. FIXME: should return a set of
|
||||
* std::variant<StorePath, HashPart> to get rid of this hack.
|
||||
*/
|
||||
virtual StorePathSet queryAllValidPaths()
|
||||
{ unsupported("queryAllValidPaths"); }
|
||||
virtual kj::Promise<Result<StorePathSet>> queryAllValidPaths()
|
||||
try { unsupported("queryAllValidPaths"); } catch (...) { return {result::current_exception()}; }
|
||||
|
||||
constexpr static const char * MissingName = "x";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user