From 47f7e5585bbb9a6acfaddda7327ba4eeb5b662c2 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 21 Mar 2018 22:56:02 +0100 Subject: Make 'nix copy --from ssh://...' run in constant memory For instance, this reduced the memory consumption of $ nix copy --from ssh://localhost --to ~/my-nix /nix/store/1n7x0yv8vq6zi90hfmian84vdhd04bgp-blender-2.79a from 632 MiB to 16 MiB. --- src/libstore/ssh-store.cc | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) (limited to 'src/libstore/ssh-store.cc') diff --git a/src/libstore/ssh-store.cc b/src/libstore/ssh-store.cc index 398408ea8d78..39205ae2ce12 100644 --- a/src/libstore/ssh-store.cc +++ b/src/libstore/ssh-store.cc @@ -63,29 +63,12 @@ private: }; }; - -class ForwardSource : public Source -{ - Source & readSource; - Sink & writeSink; -public: - ForwardSource(Source & readSource, Sink & writeSink) : readSource(readSource), writeSink(writeSink) {} - size_t read(unsigned char * data, size_t len) override - { - auto n = readSource.read(data, len); - writeSink(data, n); - return n; - } -}; - void SSHStore::narFromPath(const Path & path, Sink & sink) { auto conn(connections->get()); conn->to << wopNarFromPath << path; conn->processStderr(); - ParseSink ps; - auto fwd = ForwardSource(conn->from, sink); - parseDump(ps, fwd); + copyNAR(conn->from, sink); } ref SSHStore::getFSAccessor() -- cgit 1.4.1