mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-14 18:26:16 +02:00
nix-prefetch-url: Run in constant memory when using RemoteStore
Fixes #3684.
This commit is contained in:
parent
062a584f12
commit
06e3dd9005
1 changed files with 15 additions and 8 deletions
|
@ -10,6 +10,7 @@
|
||||||
#include "../nix/legacy.hh"
|
#include "../nix/legacy.hh"
|
||||||
#include "progress-bar.hh"
|
#include "progress-bar.hh"
|
||||||
#include "tarfile.hh"
|
#include "tarfile.hh"
|
||||||
|
#include "archive.hh"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
@ -200,8 +201,10 @@ static int _main(int argc, char * * argv)
|
||||||
tmpFile = unpacked;
|
tmpFile = unpacked;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: inefficient; addToStore() will also hash
|
/* FIXME: inefficient: we're reading/hashing 'tmpFile'
|
||||||
this. */
|
three times. */
|
||||||
|
auto [narHash, narSize] = hashPath(htSHA256, tmpFile);
|
||||||
|
|
||||||
hash = unpack ? hashPath(ht, tmpFile).first : hashFile(ht, tmpFile);
|
hash = unpack ? hashPath(ht, tmpFile).first : hashFile(ht, tmpFile);
|
||||||
|
|
||||||
if (expectedHash != Hash(ht) && expectedHash != hash)
|
if (expectedHash != Hash(ht) && expectedHash != hash)
|
||||||
|
@ -209,13 +212,17 @@ static int _main(int argc, char * * argv)
|
||||||
|
|
||||||
const auto recursive = unpack ? FileIngestionMethod::Recursive : FileIngestionMethod::Flat;
|
const auto recursive = unpack ? FileIngestionMethod::Recursive : FileIngestionMethod::Flat;
|
||||||
|
|
||||||
/* Copy the file to the Nix store. FIXME: if RemoteStore
|
storePath = store->makeFixedOutputPath(recursive, hash, name);
|
||||||
implemented addToStoreFromDump() and downloadFile()
|
|
||||||
supported a sink, we could stream the download directly
|
|
||||||
into the Nix store. */
|
|
||||||
storePath = store->addToStore(name, tmpFile, recursive, ht);
|
|
||||||
|
|
||||||
assert(*storePath == store->makeFixedOutputPath(recursive, hash, name));
|
/* Copy the file to the Nix store. */
|
||||||
|
ValidPathInfo info(*storePath);
|
||||||
|
info.narHash = narHash;
|
||||||
|
info.narSize = narSize;
|
||||||
|
info.ca = FixedOutputHash { .method = recursive, .hash = hash };
|
||||||
|
auto source = sinkToSource([&](Sink & sink) {
|
||||||
|
dumpPath(tmpFile, sink);
|
||||||
|
});
|
||||||
|
store->addToStore(info, *source);
|
||||||
}
|
}
|
||||||
|
|
||||||
stopProgressBar();
|
stopProgressBar();
|
||||||
|
|
Loading…
Reference in a new issue