From d7ed86ceb1af865592435c3672a39677be438d47 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Fri, 29 Aug 2025 16:10:25 -0400 Subject: [PATCH] Move deleting redirected outputs in to `cleanupBuild` It is only done in the `force = true` case, and the only `cleanupBuild(true)` call is right after where it used to be, so this has the exact same behavior as before. --- src/libstore/unix/build/derivation-builder.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/libstore/unix/build/derivation-builder.cc b/src/libstore/unix/build/derivation-builder.cc index f837efe5a..b81deaddc 100644 --- a/src/libstore/unix/build/derivation-builder.cc +++ b/src/libstore/unix/build/derivation-builder.cc @@ -542,10 +542,6 @@ SingleDrvOutputs DerivationBuilderImpl::unprepareBuild() being valid. */ auto builtOutputs = registerOutputs(); - /* Delete unused redirected outputs (when doing hash rewriting). */ - for (auto & i : redirectedOutputs) - deletePath(store.Store::toRealPath(i.second)); - cleanupBuild(true); return builtOutputs; @@ -1855,6 +1851,12 @@ SingleDrvOutputs DerivationBuilderImpl::registerOutputs() void DerivationBuilderImpl::cleanupBuild(bool force) { + if (force) { + /* Delete unused redirected outputs (when doing hash rewriting). */ + for (auto & i : redirectedOutputs) + deletePath(store.Store::toRealPath(i.second)); + } + if (topTmpDir != "") { /* As an extra precaution, even in the event of `deletePath` failing to * clean up, the `tmpDir` will be chowned as if we were to move