mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-23 06:26:15 +02:00
Avoid a redundant hash
This commit is contained in:
parent
5dff49f661
commit
8efa23bb99
1 changed files with 5 additions and 2 deletions
|
@ -229,14 +229,17 @@ ValidPathInfo Store::addToStoreSlow(std::string_view name, const Path & srcPath,
|
||||||
/* FIXME: inefficient: we're reading/hashing 'tmpFile' three
|
/* FIXME: inefficient: we're reading/hashing 'tmpFile' three
|
||||||
times. */
|
times. */
|
||||||
|
|
||||||
|
auto [narHash, narSize] = hashPath(htSHA256, srcPath);
|
||||||
|
|
||||||
auto hash = method == FileIngestionMethod::Recursive
|
auto hash = method == FileIngestionMethod::Recursive
|
||||||
? hashPath(hashAlgo, srcPath).first
|
? hashAlgo == htSHA256
|
||||||
|
? narHash
|
||||||
|
: hashPath(hashAlgo, srcPath).first
|
||||||
: hashFile(hashAlgo, srcPath);
|
: hashFile(hashAlgo, srcPath);
|
||||||
|
|
||||||
if (expectedCAHash && expectedCAHash != hash)
|
if (expectedCAHash && expectedCAHash != hash)
|
||||||
throw Error("hash mismatch for '%s'", srcPath);
|
throw Error("hash mismatch for '%s'", srcPath);
|
||||||
|
|
||||||
auto [narHash, narSize] = hashPath(htSHA256, srcPath);
|
|
||||||
ValidPathInfo info(makeFixedOutputPath(method, hash, name));
|
ValidPathInfo info(makeFixedOutputPath(method, hash, name));
|
||||||
info.narHash = narHash;
|
info.narHash = narHash;
|
||||||
info.narSize = narSize;
|
info.narSize = narSize;
|
||||||
|
|
Loading…
Reference in a new issue