libstore: asyncify Store::queryDerivationOutputs
Change-Id: Ie9f67ff0b9193978021d58afb2bf2758288215f7
This commit is contained in:
@@ -248,7 +248,7 @@ try {
|
||||
auto drv = TRY_AWAIT(store->derivationFromPath(storePath));
|
||||
StorePathSet outputs;
|
||||
if (forceRealise)
|
||||
co_return store->queryDerivationOutputs(storePath);
|
||||
co_return TRY_AWAIT(store->queryDerivationOutputs(storePath));
|
||||
for (auto & i : drv.outputsAndOptPaths(*store)) {
|
||||
if (!i.second.second)
|
||||
throw UsageError("Cannot use output path of floating content-addressed derivation until we know what it is (e.g. by building it)");
|
||||
|
||||
@@ -358,7 +358,7 @@ static void performOp(AsyncIoRoot & aio, TunnelLogger * logger, ref<Store> store
|
||||
case WorkerProto::Op::QueryDerivationOutputs: {
|
||||
// Only sent if server presents proto version <= 1.21
|
||||
REMOVE_AFTER_DROPPING_PROTO_MINOR(21);
|
||||
paths = store->queryDerivationOutputs(path);
|
||||
paths = aio.blockOn(store->queryDerivationOutputs(path));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
||||
@@ -319,16 +319,18 @@ StorePathSet RemoteStore::queryValidDerivers(const StorePath & path)
|
||||
}
|
||||
|
||||
|
||||
StorePathSet RemoteStore::queryDerivationOutputs(const StorePath & path)
|
||||
{
|
||||
kj::Promise<Result<StorePathSet>> RemoteStore::queryDerivationOutputs(const StorePath & path)
|
||||
try {
|
||||
if (GET_PROTOCOL_MINOR(getProtocol()) >= 22) {
|
||||
return Store::queryDerivationOutputs(path);
|
||||
co_return TRY_AWAIT(Store::queryDerivationOutputs(path));
|
||||
}
|
||||
REMOVE_AFTER_DROPPING_PROTO_MINOR(21);
|
||||
auto conn(getConnection());
|
||||
conn->to << WorkerProto::Op::QueryDerivationOutputs << 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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
|
||||
StorePathSet queryValidDerivers(const StorePath & path) override;
|
||||
|
||||
StorePathSet queryDerivationOutputs(const StorePath & path) override;
|
||||
kj::Promise<Result<StorePathSet>> queryDerivationOutputs(const StorePath & path) override;
|
||||
|
||||
std::map<std::string, std::optional<StorePath>> queryPartialDerivationOutputMap(const StorePath & path, Store * evalStore = nullptr) override;
|
||||
std::optional<StorePath> queryPathFromHashPart(const std::string & hashPart) override;
|
||||
|
||||
@@ -605,14 +605,16 @@ OutputPathMap Store::queryDerivationOutputMap(const StorePath & path, Store * ev
|
||||
return result;
|
||||
}
|
||||
|
||||
StorePathSet Store::queryDerivationOutputs(const StorePath & path)
|
||||
{
|
||||
kj::Promise<Result<StorePathSet>> Store::queryDerivationOutputs(const StorePath & path)
|
||||
try {
|
||||
auto outputMap = this->queryDerivationOutputMap(path);
|
||||
StorePathSet outputPaths;
|
||||
for (auto & i: outputMap) {
|
||||
outputPaths.emplace(std::move(i.second));
|
||||
}
|
||||
return outputPaths;
|
||||
co_return outputPaths;
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -444,7 +444,7 @@ public:
|
||||
/**
|
||||
* Query the outputs of the derivation denoted by `path`.
|
||||
*/
|
||||
virtual StorePathSet queryDerivationOutputs(const StorePath & path);
|
||||
virtual kj::Promise<Result<StorePathSet>> queryDerivationOutputs(const StorePath & path);
|
||||
|
||||
/**
|
||||
* Query the mapping outputName => outputPath for the given
|
||||
|
||||
Reference in New Issue
Block a user