libstore: asyncify Store::substitutePaths

Change-Id: I8cb6822ad9145fbcf0f98f32c121482c3a3db2a8
This commit is contained in:
eldritch horrors
2025-02-01 21:48:48 +00:00
parent 48519448e2
commit a51380645f
4 changed files with 11 additions and 6 deletions
+1 -1
View File
@@ -881,7 +881,7 @@ static void opServe(AsyncIoRoot & aio, Strings opFlags, Strings opArgs)
store->addTempRoot(path);
if (substitute && writeAllowed) {
store->substitutePaths(paths);
aio.blockOn(store->substitutePaths(paths));
}
auto valid = store->queryValidPaths(paths);
+1 -1
View File
@@ -289,7 +289,7 @@ static void performOp(AsyncIoRoot & aio, TunnelLogger * logger, ref<Store> store
logger->startWork();
if (substitute) {
store->substitutePaths(paths);
aio.blockOn(store->substitutePaths(paths));
}
auto res = store->queryValidPaths(paths, substitute);
logger->stopWork();
+8 -3
View File
@@ -4,6 +4,7 @@
#include "lix/libstore/store-api.hh"
#include "lix/libstore/nar-info-disk-cache.hh"
#include "lix/libutil/async.hh"
#include "lix/libutil/result.hh"
#include "lix/libutil/thread-pool.hh"
#include "lix/libutil/url.hh"
#include "lix/libutil/archive.hh"
@@ -801,8 +802,8 @@ std::shared_ptr<const Realisation> Store::queryRealisation(const DrvOutput & id)
return info;
}
void Store::substitutePaths(const StorePathSet & paths)
{
kj::Promise<Result<void>> Store::substitutePaths(const StorePathSet & paths)
try {
std::vector<DerivedPath> paths2;
for (auto & path : paths)
if (!path.isDerivation())
@@ -816,10 +817,14 @@ void Store::substitutePaths(const StorePathSet & paths)
try {
std::vector<DerivedPath> subs;
for (auto & p : willSubstitute) subs.emplace_back(DerivedPath::Opaque{p});
RUN_ASYNC_IN_NEW_THREAD(buildPaths(subs));
TRY_AWAIT(buildPaths(subs));
} catch (Error & e) {
logWarning(e.info());
}
co_return result::success();
} catch (...) {
co_return result::current_exception();
}
+1 -1
View File
@@ -354,7 +354,7 @@ public:
* implements nix-copy-closure's --use-substitutes
* flag.
*/
void substitutePaths(const StorePathSet & paths);
kj::Promise<Result<void>> substitutePaths(const StorePathSet & paths);
/**
* Query which of the given paths is valid. Optionally, try to