Also make the backwards compatible case of RemoteStore::addToStore run in constant memory

Just because we can.
This commit is contained in:
Eelco Dolstra 2018-03-21 23:46:03 +01:00
parent 97002b684c
commit ec91840e70

View file

@ -385,21 +385,21 @@ void RemoteStore::addToStore(const ValidPathInfo & info, Source & source,
if (GET_PROTOCOL_MINOR(conn->daemonVersion) < 18) { if (GET_PROTOCOL_MINOR(conn->daemonVersion) < 18) {
conn->to << wopImportPaths; conn->to << wopImportPaths;
StringSink sink; auto source2 = sinkToSource([&](Sink & sink) {
sink << 1 // == path follows sink << 1 // == path follows
; ;
copyNAR(source, sink); copyNAR(source, sink);
sink sink
<< exportMagic << exportMagic
<< info.path << info.path
<< info.references << info.references
<< info.deriver << info.deriver
<< 0 // == no legacy signature << 0 // == no legacy signature
<< 0 // == no path follows << 0 // == no path follows
; ;
});
StringSource source(*sink.s); conn->processStderr(0, source2.get());
conn->processStderr(0, &source);
auto importedPaths = readStorePaths<PathSet>(*this, conn->from); auto importedPaths = readStorePaths<PathSet>(*this, conn->from);
assert(importedPaths.size() <= 1); assert(importedPaths.size() <= 1);