Make 'nix copy --to daemon' run in constant memory

This commit is contained in:
Eelco Dolstra 2018-03-21 23:42:21 +01:00
parent 11898d6a37
commit 97002b684c
2 changed files with 4 additions and 5 deletions

View file

@ -377,7 +377,7 @@ Path RemoteStore::queryPathFromHashPart(const string & hashPart)
} }
void RemoteStore::addToStore(const ValidPathInfo & info, const ref<std::string> & nar, void RemoteStore::addToStore(const ValidPathInfo & info, Source & source,
RepairFlag repair, CheckSigsFlag checkSigs, std::shared_ptr<FSAccessor> accessor) RepairFlag repair, CheckSigsFlag checkSigs, std::shared_ptr<FSAccessor> accessor)
{ {
auto conn(connections->get()); auto conn(connections->get());
@ -388,8 +388,7 @@ void RemoteStore::addToStore(const ValidPathInfo & info, const ref<std::string>
StringSink sink; StringSink sink;
sink << 1 // == path follows sink << 1 // == path follows
; ;
assert(nar->size() % 8 == 0); copyNAR(source, sink);
sink((unsigned char *) nar->data(), nar->size());
sink sink
<< exportMagic << exportMagic
<< info.path << info.path
@ -412,7 +411,7 @@ void RemoteStore::addToStore(const ValidPathInfo & info, const ref<std::string>
<< info.references << info.registrationTime << info.narSize << info.references << info.registrationTime << info.narSize
<< info.ultimate << info.sigs << info.ca << info.ultimate << info.sigs << info.ca
<< repair << !checkSigs; << repair << !checkSigs;
conn->to(*nar); copyNAR(source, conn->to);
conn->processStderr(); conn->processStderr();
} }
} }

View file

@ -58,7 +58,7 @@ public:
void querySubstitutablePathInfos(const PathSet & paths, void querySubstitutablePathInfos(const PathSet & paths,
SubstitutablePathInfos & infos) override; SubstitutablePathInfos & infos) override;
void addToStore(const ValidPathInfo & info, const ref<std::string> & nar, void addToStore(const ValidPathInfo & info, Source & nar,
RepairFlag repair, CheckSigsFlag checkSigs, RepairFlag repair, CheckSigsFlag checkSigs,
std::shared_ptr<FSAccessor> accessor) override; std::shared_ptr<FSAccessor> accessor) override;