libstore: asyncify Store::queryValidDerivers
Change-Id: I9ac447cb57e0ba330eee216280eb3d7913c5782b
This commit is contained in:
@@ -398,8 +398,9 @@ static void opQuery(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
|
||||
case qValidDerivers: {
|
||||
StorePathSet result;
|
||||
for (auto & i : opArgs) {
|
||||
auto derivers = store->queryValidDerivers(store->followLinksToStorePath(i));
|
||||
for (const auto &i: derivers) {
|
||||
auto derivers =
|
||||
aio.blockOn(store->queryValidDerivers(store->followLinksToStorePath(i)));
|
||||
for (const auto & i : derivers) {
|
||||
result.insert(i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -386,16 +386,18 @@ DerivedPathWithInfo Installable::toDerivedPath(EvalState & state)
|
||||
return std::move(buildables[0]);
|
||||
}
|
||||
|
||||
static StorePath getDeriver(
|
||||
static kj::Promise<Result<StorePath>> getDeriver(
|
||||
ref<Store> store,
|
||||
const Installable & i,
|
||||
const StorePath & drvPath)
|
||||
{
|
||||
auto derivers = store->queryValidDerivers(drvPath);
|
||||
try {
|
||||
auto derivers = TRY_AWAIT(store->queryValidDerivers(drvPath));
|
||||
if (derivers.empty())
|
||||
throw Error("'%s' does not have a known deriver", i.what());
|
||||
// FIXME: use all derivers?
|
||||
return *derivers.begin();
|
||||
co_return *derivers.begin();
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
}
|
||||
|
||||
ref<eval_cache::EvalCache> openEvalCache(
|
||||
@@ -785,7 +787,7 @@ StorePathSet Installable::toDerivations(
|
||||
bo.path.isDerivation()
|
||||
? bo.path
|
||||
: useDeriver
|
||||
? getDeriver(store, *i, bo.path)
|
||||
? state.aio.blockOn(getDeriver(store, *i, bo.path))
|
||||
: throw Error("argument '%s' did not evaluate to a derivation", i->what()));
|
||||
},
|
||||
[&](const DerivedPath::Built & bfd) {
|
||||
|
||||
@@ -353,7 +353,7 @@ static void performOp(AsyncIoRoot & aio, TunnelLogger * logger, ref<Store> store
|
||||
break;
|
||||
}
|
||||
case WorkerProto::Op::QueryValidDerivers: {
|
||||
paths = store->queryValidDerivers(path);
|
||||
paths = aio.blockOn(store->queryValidDerivers(path));
|
||||
break;
|
||||
}
|
||||
case WorkerProto::Op::QueryDerivationOutputs: {
|
||||
|
||||
+1
-1
@@ -782,7 +782,7 @@ try {
|
||||
|
||||
/* If keep-outputs is set, then visit the derivers. */
|
||||
if (gcKeepOutputs) {
|
||||
auto derivers = queryValidDerivers(*path);
|
||||
auto derivers = TRY_AWAIT(queryValidDerivers(*path));
|
||||
for (auto & i : derivers)
|
||||
enqueue(i);
|
||||
}
|
||||
|
||||
+17
-10
@@ -1060,19 +1060,26 @@ void LocalStore::queryReferrers(const StorePath & path, StorePathSet & referrers
|
||||
}
|
||||
|
||||
|
||||
StorePathSet LocalStore::queryValidDerivers(const StorePath & path)
|
||||
{
|
||||
return retrySQLite([&]() {
|
||||
auto state = dbPool.get();
|
||||
kj::Promise<Result<StorePathSet>> LocalStore::queryValidDerivers(const StorePath & path)
|
||||
try {
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-capturing-lambda-coroutines)
|
||||
co_return TRY_AWAIT(retrySQLite([&]() -> kj::Promise<Result<StorePathSet>> {
|
||||
try {
|
||||
auto state = dbPool.get();
|
||||
|
||||
auto useQueryValidDerivers(state->stmts->QueryValidDerivers.use()(printStorePath(path)));
|
||||
auto useQueryValidDerivers(state->stmts->QueryValidDerivers.use()(printStorePath(path)));
|
||||
|
||||
StorePathSet derivers;
|
||||
while (useQueryValidDerivers.next())
|
||||
derivers.insert(parseStorePath(useQueryValidDerivers.getStr(1)));
|
||||
StorePathSet derivers;
|
||||
while (useQueryValidDerivers.next())
|
||||
derivers.insert(parseStorePath(useQueryValidDerivers.getStr(1)));
|
||||
|
||||
return derivers;
|
||||
}, always_progresses);
|
||||
co_return derivers;
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
}
|
||||
}));
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -200,7 +200,7 @@ public:
|
||||
|
||||
void queryReferrers(const StorePath & path, StorePathSet & referrers) override;
|
||||
|
||||
StorePathSet queryValidDerivers(const StorePath & path) override;
|
||||
kj::Promise<Result<StorePathSet>> queryValidDerivers(const StorePath & path) override;
|
||||
|
||||
kj::Promise<Result<std::map<std::string, std::optional<StorePath>>>>
|
||||
queryStaticPartialDerivationOutputMap(const StorePath & path) override;
|
||||
|
||||
@@ -32,7 +32,7 @@ try {
|
||||
res.insert(ref);
|
||||
|
||||
if (includeOutputs)
|
||||
for (auto& i : queryValidDerivers(path))
|
||||
for (auto& i : TRY_AWAIT(queryValidDerivers(path)))
|
||||
res.insert(i);
|
||||
|
||||
if (includeDerivers && path.isDerivation())
|
||||
|
||||
@@ -317,12 +317,14 @@ void RemoteStore::queryReferrers(const StorePath & path,
|
||||
}
|
||||
|
||||
|
||||
StorePathSet RemoteStore::queryValidDerivers(const StorePath & path)
|
||||
{
|
||||
kj::Promise<Result<StorePathSet>> RemoteStore::queryValidDerivers(const StorePath & path)
|
||||
try {
|
||||
auto conn(getConnection());
|
||||
conn->to << WorkerProto::Op::QueryValidDerivers << printStorePath(path);
|
||||
conn.processStderr();
|
||||
return WorkerProto::Serialise<StorePathSet>::read(*this, *conn);
|
||||
co_return WorkerProto::Serialise<StorePathSet>::read(*this, *conn);
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
|
||||
void queryReferrers(const StorePath & path, StorePathSet & referrers) override;
|
||||
|
||||
StorePathSet queryValidDerivers(const StorePath & path) override;
|
||||
kj::Promise<Result<StorePathSet>> queryValidDerivers(const StorePath & path) override;
|
||||
|
||||
kj::Promise<Result<StorePathSet>> queryDerivationOutputs(const StorePath & path) override;
|
||||
|
||||
|
||||
@@ -440,7 +440,10 @@ public:
|
||||
* was actually used to produce `path`, which may not exist
|
||||
* anymore.)
|
||||
*/
|
||||
virtual StorePathSet queryValidDerivers(const StorePath & path) { return {}; };
|
||||
virtual kj::Promise<Result<StorePathSet>> queryValidDerivers(const StorePath & path)
|
||||
{
|
||||
return {StorePathSet{}};
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the outputs of the derivation denoted by `path`.
|
||||
|
||||
Reference in New Issue
Block a user