Skip to content

Commit

Permalink
Fix NixOS#2984: attempt to copy if unlinking source directory fails
Browse files Browse the repository at this point in the history
  • Loading branch information
yorickvP committed Jan 15, 2020
1 parent 8b09105 commit 3b316bf
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/libstore/build.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3591,8 +3591,15 @@ void DerivationGoal::registerOutputs()
if (buildMode == bmRepair)
replaceValidPath(path, actualPath);
else
if (buildMode != bmCheck && rename(actualPath.c_str(), worker.store.toRealPath(path).c_str()) == -1)
throw SysError(format("moving build output '%1%' from the sandbox to the Nix store") % path);
if (buildMode != bmCheck && rename(actualPath.c_str(), worker.store.toRealPath(path).c_str())) {
if(errno == EACCESS) {
// No need to free since we are in a chroot, and that gets deleted later.
// Hope it's a source problem
copyPath(actualPath, worker.store.toRealPath(path));
} else {
throw SysError(format("moving build output '%1%' from the sandbox to the Nix store") % path);
}
}
}
if (buildMode != bmCheck) actualPath = worker.store.toRealPath(path);
}
Expand Down

0 comments on commit 3b316bf

Please sign in to comment.