From df8851f286a407c46ea9107ca403888291f1afbe Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Thu, 2 May 2024 01:25:46 +0200 Subject: libutil: rewrite RewritingSink as source the rewriting sink was just broken. when given a rewrite set that contained a key that is also a proper infix of another key it was possible to produce an incorrectly rewritten result if the writer used the wrong block size. fixing this duplicates rewriteStrings, to avoid this we'll rewrite rewriteStrings to use RewritingSource in a new mode that'll allow rewrites we had previously forbidden. Change-Id: I57fa0a9a994e654e11d07172b8e31d15f0b7e8c0 --- src/libstore/build/local-derivation-goal.cc | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/libstore/build') diff --git a/src/libstore/build/local-derivation-goal.cc b/src/libstore/build/local-derivation-goal.cc index d523ef51f..a071883bb 100644 --- a/src/libstore/build/local-derivation-goal.cc +++ b/src/libstore/build/local-derivation-goal.cc @@ -2150,14 +2150,10 @@ SingleDrvOutputs LocalDerivationGoal::registerOutputs() if (!rewrites.empty()) { debug("rewriting hashes in '%1%'; cross fingers", actualPath); - /* FIXME: Is this actually streaming? */ - auto source = sinkToSource([&](Sink & nextSink) { - RewritingSink rsink(rewrites, nextSink); - rsink << dumpPath(actualPath); - rsink.flush(); - }); + GeneratorSource dump{dumpPath(actualPath)}; + RewritingSource rewritten(rewrites, dump); Path tmpPath = actualPath + ".tmp"; - restorePath(tmpPath, *source); + restorePath(tmpPath, rewritten); deletePath(actualPath); movePath(tmpPath, actualPath); -- cgit v1.2.3