1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-09 03:56:01 +01:00

registerOutputs: Hoist up optimizePath call and comment rationale

This commit is contained in:
John Ericson 2025-10-16 16:59:19 -04:00
parent 646d1f5ff7
commit 35b08b71a4

View file

@ -1783,16 +1783,26 @@ SingleDrvOutputs DerivationBuilderImpl::registerOutputs()
if (buildMode == bmRepair) { if (buildMode == bmRepair) {
/* Path already exists, need to replace it */ /* Path already exists, need to replace it */
replaceValidPath(store.toRealPath(finalDestPath), actualPath); replaceValidPath(store.toRealPath(finalDestPath), actualPath);
/* Optimize store object we just replaced with new
(not-yet-optimized) data. */
store.optimisePath(
store.toRealPath(finalDestPath), NoRepair); // FIXME: combine with scanForReferences()
} else if (store.isValidPath(newInfo.path)) { } else if (store.isValidPath(newInfo.path)) {
/* Path already exists because CA path produced by something /* Path already exists because CA path produced by something
else. No moving needed. */ else. No moving needed. */
assert(newInfo.ca); assert(newInfo.ca);
/* Can delete our scratch copy now. */ /* Can delete our scratch copy now. */
deletePath(actualPath); deletePath(actualPath);
/* Presume already-existing store object is already
optimized. */
} else { } else {
auto destPath = store.toRealPath(finalDestPath); auto destPath = store.toRealPath(finalDestPath);
deletePath(destPath); deletePath(destPath);
movePath(actualPath, destPath); movePath(actualPath, destPath);
/* Optimize store object we just installed from new
(not-yet-optimized) data. */
store.optimisePath(
store.toRealPath(finalDestPath), NoRepair); // FIXME: combine with scanForReferences()
} }
} }
@ -1804,10 +1814,6 @@ SingleDrvOutputs DerivationBuilderImpl::registerOutputs()
debug("unreferenced input: '%1%'", store.printStorePath(i)); debug("unreferenced input: '%1%'", store.printStorePath(i));
} }
if (!store.isValidPath(newInfo.path))
store.optimisePath(
store.toRealPath(finalDestPath), NoRepair); // FIXME: combine with scanForReferences()
newInfo.deriver = drvPath; newInfo.deriver = drvPath;
newInfo.ultimate = true; newInfo.ultimate = true;
store.signPathInfo(newInfo); store.signPathInfo(newInfo);