Use a RewritingSink in derivation goal

Possibly this will make it stream
This commit is contained in:
Théophane Hufschmitt 2023-03-17 15:51:08 +01:00
parent 3ebe1341ab
commit a917fb0d53

View file

@ -2384,13 +2384,16 @@ SingleDrvOutputs LocalDerivationGoal::registerOutputs()
if (!outputRewrites.empty()) {
debug("rewriting hashes in '%1%'; cross fingers", actualPath);
/* FIXME: this is in-memory. */
StringSink sink;
dumpPath(actualPath, sink);
/* FIXME: Is this actually streaming? */
auto source = sinkToSource([&](Sink & nextSink) {
RewritingSink rsink(outputRewrites, nextSink);
dumpPath(actualPath, rsink);
rsink.flush();
});
Path tmpPath = actualPath + ".tmp";
restorePath(tmpPath, *source);
deletePath(actualPath);
sink.s = rewriteStrings(sink.s, outputRewrites);
StringSource source(sink.s);
restorePath(actualPath, source);
movePath(tmpPath, actualPath);
/* FIXME: set proper permissions in restorePath() so
we don't have to do another traversal. */