libstore: asyncify Store::querySubstitutablePathInfos
this also calls getDefaultSubstituters. Change-Id: I9c80d8b8311a712a3e73964445c42d10a5dab7db
This commit is contained in:
@@ -776,7 +776,7 @@ static void performOp(AsyncIoRoot & aio, TunnelLogger * logger, ref<Store> store
|
||||
auto path = store->parseStorePath(readString(from));
|
||||
logger->startWork();
|
||||
SubstitutablePathInfos infos;
|
||||
store->querySubstitutablePathInfos({{path, std::nullopt}}, infos);
|
||||
aio.blockOn(store->querySubstitutablePathInfos({{path, std::nullopt}}, infos));
|
||||
logger->stopWork();
|
||||
auto i = infos.find(path);
|
||||
if (i == infos.end())
|
||||
@@ -801,7 +801,7 @@ static void performOp(AsyncIoRoot & aio, TunnelLogger * logger, ref<Store> store
|
||||
} else
|
||||
pathsMap = WorkerProto::Serialise<StorePathCAMap>::read(*store, rconn);
|
||||
logger->startWork();
|
||||
store->querySubstitutablePathInfos(pathsMap, infos);
|
||||
aio.blockOn(store->querySubstitutablePathInfos(pathsMap, infos));
|
||||
logger->stopWork();
|
||||
to << infos.size();
|
||||
for (auto & i : infos) {
|
||||
|
||||
@@ -159,12 +159,12 @@ struct QueryMissingContext
|
||||
|
||||
SubstitutablePathInfos infos;
|
||||
auto * cap = getDerivationCA(*drv);
|
||||
store.querySubstitutablePathInfos({
|
||||
aio.blockOn(store.querySubstitutablePathInfos({
|
||||
{
|
||||
outPath,
|
||||
cap ? std::optional { *cap } : std::nullopt,
|
||||
},
|
||||
}, infos);
|
||||
}, infos));
|
||||
|
||||
if (infos.empty()) {
|
||||
drvState_->lock()->done = true;
|
||||
@@ -198,7 +198,7 @@ struct QueryMissingContext
|
||||
std::visit(
|
||||
overloaded{
|
||||
[&](const DerivedPath::Built & bfd) { doPathBuilt(aio, bfd); },
|
||||
[&](const DerivedPath::Opaque & bo) { doPathOpaque(bo); },
|
||||
[&](const DerivedPath::Opaque & bo) { doPathOpaque(aio, bo); },
|
||||
},
|
||||
req.raw()
|
||||
);
|
||||
@@ -280,12 +280,12 @@ struct QueryMissingContext
|
||||
}
|
||||
}
|
||||
|
||||
void doPathOpaque(const DerivedPath::Opaque & bo)
|
||||
void doPathOpaque(AsyncIoRoot & aio, const DerivedPath::Opaque & bo)
|
||||
{
|
||||
if (store.isValidPath(bo.path)) return;
|
||||
|
||||
SubstitutablePathInfos infos;
|
||||
store.querySubstitutablePathInfos({{bo.path, std::nullopt}}, infos);
|
||||
aio.blockOn(store.querySubstitutablePathInfos({{bo.path, std::nullopt}}, infos));
|
||||
|
||||
if (infos.empty()) {
|
||||
auto state(state_.lock());
|
||||
|
||||
@@ -239,9 +239,9 @@ try {
|
||||
}
|
||||
|
||||
|
||||
void RemoteStore::querySubstitutablePathInfos(const StorePathCAMap & pathsMap, SubstitutablePathInfos & infos)
|
||||
{
|
||||
if (pathsMap.empty()) return;
|
||||
kj::Promise<Result<void>> RemoteStore::querySubstitutablePathInfos(const StorePathCAMap & pathsMap, SubstitutablePathInfos & infos)
|
||||
try {
|
||||
if (pathsMap.empty()) return {result::success()};
|
||||
|
||||
auto conn(getConnection());
|
||||
|
||||
@@ -265,6 +265,10 @@ void RemoteStore::querySubstitutablePathInfos(const StorePathCAMap & pathsMap, S
|
||||
info.downloadSize = readLongLong(conn->from);
|
||||
info.narSize = readLongLong(conn->from);
|
||||
}
|
||||
|
||||
return {result::success()};
|
||||
} catch (...) {
|
||||
return {result::current_exception()};
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
|
||||
kj::Promise<Result<StorePathSet>> querySubstitutablePaths(const StorePathSet & paths) override;
|
||||
|
||||
void querySubstitutablePathInfos(const StorePathCAMap & paths,
|
||||
kj::Promise<Result<void>> querySubstitutablePathInfos(const StorePathCAMap & paths,
|
||||
SubstitutablePathInfos & infos) override;
|
||||
|
||||
/**
|
||||
|
||||
@@ -604,9 +604,9 @@ StorePathSet Store::queryDerivationOutputs(const StorePath & path)
|
||||
}
|
||||
|
||||
|
||||
void Store::querySubstitutablePathInfos(const StorePathCAMap & paths, SubstitutablePathInfos & infos)
|
||||
{
|
||||
if (!settings.useSubstitutes) return;
|
||||
kj::Promise<Result<void>> Store::querySubstitutablePathInfos(const StorePathCAMap & paths, SubstitutablePathInfos & infos)
|
||||
try {
|
||||
if (!settings.useSubstitutes) co_return result::success();
|
||||
for (auto & sub : getDefaultSubstituters()) {
|
||||
for (auto & path : paths) {
|
||||
if (infos.count(path.first))
|
||||
@@ -654,6 +654,10 @@ void Store::querySubstitutablePathInfos(const StorePathCAMap & paths, Substituta
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
co_return result::success();
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -489,7 +489,7 @@ public:
|
||||
* If a path does not have substitute info, it's omitted from the
|
||||
* resulting ‘infos’ map.
|
||||
*/
|
||||
virtual void querySubstitutablePathInfos(const StorePathCAMap & paths,
|
||||
virtual kj::Promise<Result<void>> querySubstitutablePathInfos(const StorePathCAMap & paths,
|
||||
SubstitutablePathInfos & infos);
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user