mirror of
https://github.com/NixOS/nix.git
synced 2025-11-08 19:46:02 +01:00
registerOutputs: Swap check and non-check cases in the code
This is the exact same control flow, but with one less branch because it becomes redundant.
This commit is contained in:
parent
d596b9754e
commit
050ff4c6a3
1 changed files with 18 additions and 21 deletions
|
|
@ -1737,27 +1737,6 @@ SingleDrvOutputs DerivationBuilderImpl::registerOutputs()
|
|||
dynamicOutputLock.lockPaths({store.toRealPath(finalDestPath)});
|
||||
}
|
||||
|
||||
/* Move files, if needed */
|
||||
if (store.toRealPath(finalDestPath) != actualPath) {
|
||||
if (buildMode == bmRepair) {
|
||||
/* Path already exists, need to replace it */
|
||||
replaceValidPath(store.toRealPath(finalDestPath), actualPath);
|
||||
} else if (buildMode == bmCheck) {
|
||||
/* Path already exists, and we want to compare, so we leave out
|
||||
new path in place. */
|
||||
} else if (store.isValidPath(newInfo.path)) {
|
||||
/* Path already exists because CA path produced by something
|
||||
else. No moving needed. */
|
||||
assert(newInfo.ca);
|
||||
/* Can delete our scratch copy now. */
|
||||
deletePath(actualPath);
|
||||
} else {
|
||||
auto destPath = store.toRealPath(finalDestPath);
|
||||
deletePath(destPath);
|
||||
movePath(actualPath, destPath);
|
||||
}
|
||||
}
|
||||
|
||||
if (buildMode == bmCheck) {
|
||||
/* Check against already registered outputs */
|
||||
|
||||
|
|
@ -1799,6 +1778,24 @@ SingleDrvOutputs DerivationBuilderImpl::registerOutputs()
|
|||
} else {
|
||||
/* do tasks relating to registering these outputs */
|
||||
|
||||
/* Move files, if needed */
|
||||
if (store.toRealPath(finalDestPath) != actualPath) {
|
||||
if (buildMode == bmRepair) {
|
||||
/* Path already exists, need to replace it */
|
||||
replaceValidPath(store.toRealPath(finalDestPath), actualPath);
|
||||
} else if (store.isValidPath(newInfo.path)) {
|
||||
/* Path already exists because CA path produced by something
|
||||
else. No moving needed. */
|
||||
assert(newInfo.ca);
|
||||
/* Can delete our scratch copy now. */
|
||||
deletePath(actualPath);
|
||||
} else {
|
||||
auto destPath = store.toRealPath(finalDestPath);
|
||||
deletePath(destPath);
|
||||
movePath(actualPath, destPath);
|
||||
}
|
||||
}
|
||||
|
||||
/* For debugging, print out the referenced and unreferenced paths. */
|
||||
for (auto & i : inputPaths) {
|
||||
if (references.count(i))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue