From 97002b684c902dadcd351a67208f9c2a88ff8f8f Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 21 Mar 2018 23:42:21 +0100 Subject: [PATCH] Make 'nix copy --to daemon' run in constant memory --- src/libstore/remote-store.cc | 7 +++---- src/libstore/remote-store.hh | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc index 8f0b65557..1fd33c5a9 100644 --- a/src/libstore/remote-store.cc +++ b/src/libstore/remote-store.cc @@ -377,7 +377,7 @@ Path RemoteStore::queryPathFromHashPart(const string & hashPart) } -void RemoteStore::addToStore(const ValidPathInfo & info, const ref & nar, +void RemoteStore::addToStore(const ValidPathInfo & info, Source & source, RepairFlag repair, CheckSigsFlag checkSigs, std::shared_ptr accessor) { auto conn(connections->get()); @@ -388,8 +388,7 @@ void RemoteStore::addToStore(const ValidPathInfo & info, const ref StringSink sink; sink << 1 // == path follows ; - assert(nar->size() % 8 == 0); - sink((unsigned char *) nar->data(), nar->size()); + copyNAR(source, sink); sink << exportMagic << info.path @@ -412,7 +411,7 @@ void RemoteStore::addToStore(const ValidPathInfo & info, const ref << info.references << info.registrationTime << info.narSize << info.ultimate << info.sigs << info.ca << repair << !checkSigs; - conn->to(*nar); + copyNAR(source, conn->to); conn->processStderr(); } } diff --git a/src/libstore/remote-store.hh b/src/libstore/remote-store.hh index 0cc20bf94..95fa59a20 100644 --- a/src/libstore/remote-store.hh +++ b/src/libstore/remote-store.hh @@ -58,7 +58,7 @@ public: void querySubstitutablePathInfos(const PathSet & paths, SubstitutablePathInfos & infos) override; - void addToStore(const ValidPathInfo & info, const ref & nar, + void addToStore(const ValidPathInfo & info, Source & nar, RepairFlag repair, CheckSigsFlag checkSigs, std::shared_ptr accessor) override;