From ec91840e70a7dbe59669e08f83ddad149bfba906 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 21 Mar 2018 23:46:03 +0100 Subject: [PATCH] Also make the backwards compatible case of RemoteStore::addToStore run in constant memory Just because we can. --- src/libstore/remote-store.cc | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc index 1fd33c5a9..080cef93d 100644 --- a/src/libstore/remote-store.cc +++ b/src/libstore/remote-store.cc @@ -385,21 +385,21 @@ void RemoteStore::addToStore(const ValidPathInfo & info, Source & source, if (GET_PROTOCOL_MINOR(conn->daemonVersion) < 18) { conn->to << wopImportPaths; - StringSink sink; - sink << 1 // == path follows - ; - copyNAR(source, sink); - sink - << exportMagic - << info.path - << info.references - << info.deriver - << 0 // == no legacy signature - << 0 // == no path follows - ; + auto source2 = sinkToSource([&](Sink & sink) { + sink << 1 // == path follows + ; + copyNAR(source, sink); + sink + << exportMagic + << info.path + << info.references + << info.deriver + << 0 // == no legacy signature + << 0 // == no path follows + ; + }); - StringSource source(*sink.s); - conn->processStderr(0, &source); + conn->processStderr(0, source2.get()); auto importedPaths = readStorePaths(*this, conn->from); assert(importedPaths.size() <= 1);