libstore: asyncify RealisedPath::closure

Change-Id: Ibc81c4cd504665410542274d2ffe97c72c347ac2
This commit is contained in:
eldritch horrors
2025-02-23 17:18:48 +00:00
parent a514e22166
commit bd8272faec
3 changed files with 22 additions and 13 deletions
+18 -9
View File
@@ -1,6 +1,7 @@
#include "lix/libstore/realisation.hh"
#include "lix/libstore/store-api.hh"
#include "lix/libutil/closure.hh"
#include "lix/libutil/result.hh"
#include <nlohmann/json.hpp>
namespace nix {
@@ -158,11 +159,11 @@ bool Realisation::isCompatibleWith(const Realisation & other) const
return false;
}
void RealisedPath::closure(
kj::Promise<Result<void>> RealisedPath::closure(
Store& store,
const RealisedPath::Set& startPaths,
RealisedPath::Set& ret)
{
try {
// FIXME: This only builds the store-path closure, not the real realisation
// closure
StorePathSet initialStorePaths, pathsClosure;
@@ -171,18 +172,26 @@ void RealisedPath::closure(
store.computeFSClosure(initialStorePaths, pathsClosure);
ret.insert(startPaths.begin(), startPaths.end());
ret.insert(pathsClosure.begin(), pathsClosure.end());
co_return result::success();
} catch (...) {
co_return result::current_exception();
}
void RealisedPath::closure(Store& store, RealisedPath::Set & ret) const
{
RealisedPath::closure(store, {*this}, ret);
kj::Promise<Result<void>> RealisedPath::closure(Store& store, RealisedPath::Set & ret) const
try {
TRY_AWAIT(RealisedPath::closure(store, {*this}, ret));
co_return result::success();
} catch (...) {
co_return result::current_exception();
}
RealisedPath::Set RealisedPath::closure(Store& store) const
{
kj::Promise<Result<RealisedPath::Set>> RealisedPath::closure(Store& store) const
try {
RealisedPath::Set ret;
closure(store, ret);
return ret;
TRY_AWAIT(closure(store, ret));
co_return ret;
} catch (...) {
co_return result::current_exception();
}
} // namespace nix
+3 -3
View File
@@ -133,9 +133,9 @@ struct RealisedPath {
*/
StorePath path() const;
void closure(Store& store, Set& ret) const;
static void closure(Store& store, const Set& startPaths, Set& ret);
Set closure(Store& store) const;
kj::Promise<Result<void>> closure(Store & store, Set & ret) const;
static kj::Promise<Result<void>> closure(Store & store, const Set & startPaths, Set & ret);
kj::Promise<Result<Set>> closure(Store & store) const;
GENERATE_CMP(RealisedPath, me->raw);
};
+1 -1
View File
@@ -1317,7 +1317,7 @@ try {
if (&srcStore == &dstStore) co_return result::success();
RealisedPath::Set closure;
RealisedPath::closure(srcStore, paths, closure);
TRY_AWAIT(RealisedPath::closure(srcStore, paths, closure));
TRY_AWAIT(copyPaths(srcStore, dstStore, closure, repair, checkSigs, substitute));
co_return result::success();