Nix daemon stream old wopAddToStore

No more buffering in string.
This commit is contained in:
John Ericson 2021-11-30 20:53:10 +00:00
parent 1a9bfdc4ca
commit 70a717f7a8

View file

@ -431,25 +431,23 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
hashAlgo = parseHashType(hashAlgoRaw); hashAlgo = parseHashType(hashAlgoRaw);
} }
StringSink saved; auto dumpSource = sinkToSource([&](Sink & saved) {
TeeSource savedNARSource(from, saved); TeeSource savedNARSource(from, saved);
RetrieveRegularNARSink savedRegular { saved }; RetrieveRegularNARSink savedRegular { saved };
if (method == FileIngestionMethod::Recursive) { if (method == FileIngestionMethod::Recursive) {
/* Get the entire NAR dump from the client and save it to /* Get the entire NAR dump from the client and save it to
a string so that we can pass it to a string so that we can pass it to
addToStoreFromDump(). */ addToStoreFromDump(). */
ParseSink sink; /* null sink; just parse the NAR */ ParseSink sink; /* null sink; just parse the NAR */
parseDump(sink, savedNARSource); parseDump(sink, savedNARSource);
} else } else
parseDump(savedRegular, from); parseDump(savedRegular, from);
if (!savedRegular.regular) throw Error("regular file expected");
});
logger->startWork(); logger->startWork();
if (!savedRegular.regular) throw Error("regular file expected"); auto path = store->addToStoreFromDump(*dumpSource, baseName, method, hashAlgo);
// FIXME: try to stream directly from `from`.
StringSource dumpSource { *saved.s };
auto path = store->addToStoreFromDump(dumpSource, baseName, method, hashAlgo);
logger->stopWork(); logger->stopWork();
to << store->printStorePath(path); to << store->printStorePath(path);