diff --git a/src/libexpr/primops/fetchClosure.cc b/src/libexpr/primops/fetchClosure.cc index 0f7eafefe9e6..84bce6116ea3 100644 --- a/src/libexpr/primops/fetchClosure.cc +++ b/src/libexpr/primops/fetchClosure.cc @@ -24,6 +24,8 @@ static void runFetchClosureWithRewrite( const std::optional & toPathMaybe, Value & v) { + if (toPathMaybe) + state.store->addTempRoot(*toPathMaybe); // establish toPath or throw @@ -75,6 +77,7 @@ static void runFetchClosureWithRewrite( static void runFetchClosureWithContentAddressedPath( EvalState & state, const PosIdx pos, Store & fromStore, const StorePath & fromPath, Value & v) { + state.store->addTempRoot(fromPath); if (!state.store->isValidPath(fromPath)) copyClosure(fromStore, *state.store, RealisedPath::Set{fromPath}); @@ -104,6 +107,7 @@ static void runFetchClosureWithContentAddressedPath( static void runFetchClosureWithInputAddressedPath( EvalState & state, const PosIdx pos, Store & fromStore, const StorePath & fromPath, Value & v) { + state.store->addTempRoot(fromPath); if (!state.store->isValidPath(fromPath)) copyClosure(fromStore, *state.store, RealisedPath::Set{fromPath}); diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index 1145c2574e56..edc8daafc137 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -1040,6 +1040,9 @@ std::map copyPaths( CheckSigsFlag checkSigs, SubstituteFlag substitute) { + for (auto & path : storePaths) + dstStore.addTempRoot(path); + auto valid = dstStore.queryValidPaths(storePaths, substitute); StorePathSet missing;