diff --git a/lix/legacy/build-remote.cc b/lix/legacy/build-remote.cc index 2a1642829..091b8fe41 100644 --- a/lix/legacy/build-remote.cc +++ b/lix/legacy/build-remote.cc @@ -285,7 +285,14 @@ connected: { Activity act(*logger, lvlTalkative, actUnknown, fmt("copying dependencies to '%s'", storeUri)); - copyPaths(*store, *sshStore, store->parseStorePathSet(inputs), NoRepair, NoCheckSigs, substitute); + aio.blockOn(copyPaths( + *store, + *sshStore, + store->parseStorePathSet(inputs), + NoRepair, + NoCheckSigs, + substitute + )); } uploadLock.reset(); @@ -371,7 +378,9 @@ connected: if (auto localStore = store.dynamic_pointer_cast()) for (auto & path : missingPaths) localStore->locksHeld.insert(store->printStorePath(path)); /* FIXME: ugly */ - copyPaths(*sshStore, *store, missingPaths, NoRepair, NoCheckSigs, NoSubstitute); + aio.blockOn( + copyPaths(*sshStore, *store, missingPaths, NoRepair, NoCheckSigs, NoSubstitute) + ); } // XXX: Should be done as part of `copyPaths` for (auto & realisation : missingRealisations) { diff --git a/lix/libstore/store-api.cc b/lix/libstore/store-api.cc index 181ac3f49..76483af61 100644 --- a/lix/libstore/store-api.cc +++ b/lix/libstore/store-api.cc @@ -1141,14 +1141,14 @@ void copyStorePath( } -std::map copyPaths( +kj::Promise>> copyPaths( Store & srcStore, Store & dstStore, const RealisedPath::Set & paths, RepairFlag repair, CheckSigsFlag checkSigs, SubstituteFlag substitute) -{ +try { StorePathSet storePaths; std::set toplevelRealisations; for (auto & path : paths) { @@ -1158,7 +1158,8 @@ std::map copyPaths( toplevelRealisations.insert(*realisation); } } - auto pathsMap = copyPaths(srcStore, dstStore, storePaths, repair, checkSigs, substitute); + auto pathsMap = + TRY_AWAIT(copyPaths(srcStore, dstStore, storePaths, repair, checkSigs, substitute)); try { // Copy the realisation closure @@ -1190,17 +1191,19 @@ std::map copyPaths( throw; } - return pathsMap; + co_return pathsMap; +} catch (...) { + co_return result::current_exception(); } -std::map copyPaths( +kj::Promise>> copyPaths( Store & srcStore, Store & dstStore, const StorePathSet & storePaths, RepairFlag repair, CheckSigsFlag checkSigs, SubstituteFlag substitute) -{ +try { auto valid = dstStore.queryValidPaths(storePaths, substitute); StorePathSet missing; @@ -1285,7 +1288,9 @@ std::map copyPaths( dstStore.addMultipleToStore(pathsToCopy, act, repair, checkSigs); - return pathsMap; + co_return pathsMap; +} catch (...) { + co_return result::current_exception(); } kj::Promise> copyClosure( @@ -1296,15 +1301,15 @@ kj::Promise> copyClosure( CheckSigsFlag checkSigs, SubstituteFlag substitute) try { - if (&srcStore == &dstStore) return {result::success()}; + if (&srcStore == &dstStore) co_return result::success(); RealisedPath::Set closure; RealisedPath::closure(srcStore, paths, closure); - copyPaths(srcStore, dstStore, closure, repair, checkSigs, substitute); - return {result::success()}; + TRY_AWAIT(copyPaths(srcStore, dstStore, closure, repair, checkSigs, substitute)); + co_return result::success(); } catch (...) { - return {result::current_exception()}; + co_return result::current_exception(); } kj::Promise> copyClosure( @@ -1315,14 +1320,14 @@ kj::Promise> copyClosure( CheckSigsFlag checkSigs, SubstituteFlag substitute) try { - if (&srcStore == &dstStore) return {result::success()}; + if (&srcStore == &dstStore) co_return result::success(); StorePathSet closure; srcStore.computeFSClosure(storePaths, closure); - copyPaths(srcStore, dstStore, closure, repair, checkSigs, substitute); - return {result::success()}; + TRY_AWAIT(copyPaths(srcStore, dstStore, closure, repair, checkSigs, substitute)); + co_return result::success(); } catch (...) { - return {result::current_exception()}; + co_return result::current_exception(); } std::optional decodeValidPathInfo(const Store & store, std::istream & str, std::optional hashGiven) diff --git a/lix/libstore/store-api.hh b/lix/libstore/store-api.hh index f4e802de3..8cafe0fba 100644 --- a/lix/libstore/store-api.hh +++ b/lix/libstore/store-api.hh @@ -921,14 +921,14 @@ void copyStorePath( * * @return a map of what each path was copied to the dstStore as. */ -std::map copyPaths( +kj::Promise>> copyPaths( Store & srcStore, Store & dstStore, const RealisedPath::Set &, RepairFlag repair = NoRepair, CheckSigsFlag checkSigs = CheckSigs, SubstituteFlag substitute = NoSubstitute); -std::map copyPaths( +kj::Promise>> copyPaths( Store & srcStore, Store & dstStore, const StorePathSet & paths, RepairFlag repair = NoRepair, diff --git a/lix/nix/copy.cc b/lix/nix/copy.cc index 077a7e284..a71bfeb40 100644 --- a/lix/nix/copy.cc +++ b/lix/nix/copy.cc @@ -54,8 +54,8 @@ struct CmdCopy : virtual CopyCommand, BuiltPathsCommand stuffToCopy.insert(theseRealisations.begin(), theseRealisations.end()); } - copyPaths( - *srcStore, *dstStore, stuffToCopy, NoRepair, checkSigs, substitute); + aio().blockOn(copyPaths( + *srcStore, *dstStore, stuffToCopy, NoRepair, checkSigs, substitute)); } }; diff --git a/lix/nix/flake.cc b/lix/nix/flake.cc index dc56a2d39..8133a491f 100644 --- a/lix/nix/flake.cc +++ b/lix/nix/flake.cc @@ -1097,7 +1097,7 @@ struct CmdFlakeArchive : FlakeCommand, MixJSON, MixDryRun if (!dryRun && !dstUri.empty()) { ref dstStore = aio().blockOn(dstUri.empty() ? openStore() : openStore(dstUri)); - copyPaths(*store, *dstStore, sources); + aio().blockOn(copyPaths(*store, *dstStore, sources)); } } };