mirror of
https://github.com/NixOS/nix
synced 2025-06-27 12:41:15 +02:00
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.
This commit is contained in:
parent
92dfc22327
commit
47f7e5585b
4 changed files with 22 additions and 24 deletions
|
@ -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<FSAccessor> SSHStore::getFSAccessor()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue