diff --git a/lix/libexpr/primops/fetchClosure.cc b/lix/libexpr/primops/fetchClosure.cc index a5843d9cb..eea0e5d65 100644 --- a/lix/libexpr/primops/fetchClosure.cc +++ b/lix/libexpr/primops/fetchClosure.cc @@ -20,7 +20,8 @@ static void runFetchClosureWithRewrite(EvalState & state, const PosIdx pos, Stor // establish toPath or throw if (!toPathMaybe || !state.ctx.store->isValidPath(*toPathMaybe)) { - auto rewrittenPath = makeContentAddressed(fromStore, *state.ctx.store, fromPath); + auto rewrittenPath = + state.aio.blockOn(makeContentAddressed(fromStore, *state.ctx.store, fromPath)); if (toPathMaybe && *toPathMaybe != rewrittenPath) throw Error({ .msg = HintFmt("rewriting '%s' to content-addressed form yielded '%s', while '%s' was expected", diff --git a/lix/libstore/make-content-addressed.cc b/lix/libstore/make-content-addressed.cc index 7c4535af5..baac4ab32 100644 --- a/lix/libstore/make-content-addressed.cc +++ b/lix/libstore/make-content-addressed.cc @@ -1,14 +1,15 @@ #include "lix/libstore/make-content-addressed.hh" +#include "lix/libutil/async.hh" #include "lix/libutil/references.hh" #include "lix/libutil/strings.hh" namespace nix { -std::map makeContentAddressed( +kj::Promise>> makeContentAddressed( Store & srcStore, Store & dstStore, const StorePathSet & storePaths) -{ +try { StorePathSet closure; srcStore.computeFSClosure(storePaths, closure); @@ -73,18 +74,22 @@ std::map makeContentAddressed( remappings.insert_or_assign(std::move(path), std::move(info.path)); } - return remappings; + co_return remappings; +} catch (...) { + co_return result::current_exception(); } -StorePath makeContentAddressed( +kj::Promise> makeContentAddressed( Store & srcStore, Store & dstStore, const StorePath & fromPath) -{ - auto remappings = makeContentAddressed(srcStore, dstStore, StorePathSet { fromPath }); +try { + auto remappings = TRY_AWAIT(makeContentAddressed(srcStore, dstStore, StorePathSet{fromPath})); auto i = remappings.find(fromPath); assert(i != remappings.end()); - return i->second; + co_return i->second; +} catch (...) { + co_return result::current_exception(); } } diff --git a/lix/libstore/make-content-addressed.hh b/lix/libstore/make-content-addressed.hh index 13240ca1d..04d3ecf1a 100644 --- a/lix/libstore/make-content-addressed.hh +++ b/lix/libstore/make-content-addressed.hh @@ -7,7 +7,7 @@ namespace nix { /** Rewrite a closure of store paths to be completely content addressed. */ -std::map makeContentAddressed( +kj::Promise>> makeContentAddressed( Store & srcStore, Store & dstStore, const StorePathSet & rootPaths); @@ -16,7 +16,7 @@ std::map makeContentAddressed( * * This is a convenience function for the case where you only have one root path. */ -StorePath makeContentAddressed( +kj::Promise> makeContentAddressed( Store & srcStore, Store & dstStore, const StorePath & rootPath); diff --git a/lix/nix/make-content-addressed.cc b/lix/nix/make-content-addressed.cc index c547d8282..3acfea167 100644 --- a/lix/nix/make-content-addressed.cc +++ b/lix/nix/make-content-addressed.cc @@ -32,8 +32,8 @@ struct CmdMakeContentAddressed : virtual CopyCommand, virtual StorePathsCommand, { auto dstStore = aio().blockOn(dstUri.empty() ? openStore() : openStore(dstUri)); - auto remappings = makeContentAddressed(*srcStore, *dstStore, - StorePathSet(storePaths.begin(), storePaths.end())); + auto remappings = aio().blockOn(makeContentAddressed(*srcStore, *dstStore, + StorePathSet(storePaths.begin(), storePaths.end()))); if (json) { auto jsonRewrites = json::object();