mirror of
https://github.com/NixOS/nix
synced 2025-06-28 09:31:16 +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
|
@ -350,4 +350,21 @@ void restorePath(const Path & path, Source & source)
|
|||
}
|
||||
|
||||
|
||||
void copyNAR(Source & source, Sink & sink)
|
||||
{
|
||||
// FIXME: if 'source' is the output of dumpPath() followed by EOF,
|
||||
// we should just forward all data directly without parsing.
|
||||
|
||||
ParseSink parseSink; /* null sink; just parse the NAR */
|
||||
|
||||
LambdaSource wrapper([&](unsigned char * data, size_t len) {
|
||||
auto n = source.read(data, len);
|
||||
sink(data, n);
|
||||
return n;
|
||||
});
|
||||
|
||||
parseDump(parseSink, wrapper);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue