Skip to content

Commit dca0a80

Browse files
committed
copyStorePath(): Bail out early if the store path already exists
In rare cases (e.g. when using allowSubstitutes = false), it's possible that we simultaneously have a DerivationGoal *and* a SubstitutionGoal building the same path. So if a DerivationGoal already built the path while the SubstitutionGoal was waiting for a download slot, it saves us a superfluous download to exit early.
1 parent a18d8d6 commit dca0a80

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/libstore/store-api.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,11 @@ void copyStorePath(
981981
RepairFlag repair,
982982
CheckSigsFlag checkSigs)
983983
{
984+
/* Bail out early (before starting a download from srcStore) if
985+
dstStore already has this path. */
986+
if (!repair && dstStore.isValidPath(storePath))
987+
return;
988+
984989
auto srcUri = srcStore.getUri();
985990
auto dstUri = dstStore.getUri();
986991
auto storePathS = srcStore.printStorePath(storePath);

0 commit comments

Comments
 (0)