aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libstore/store-api.cc7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc
index 46587a49a..8d46bb436 100644
--- a/src/libstore/store-api.cc
+++ b/src/libstore/store-api.cc
@@ -229,14 +229,17 @@ ValidPathInfo Store::addToStoreSlow(std::string_view name, const Path & srcPath,
/* FIXME: inefficient: we're reading/hashing 'tmpFile' three
times. */
+ auto [narHash, narSize] = hashPath(htSHA256, srcPath);
+
auto hash = method == FileIngestionMethod::Recursive
- ? hashPath(hashAlgo, srcPath).first
+ ? hashAlgo == htSHA256
+ ? narHash
+ : hashPath(hashAlgo, srcPath).first
: hashFile(hashAlgo, srcPath);
if (expectedCAHash && expectedCAHash != hash)
throw Error("hash mismatch for '%s'", srcPath);
- auto [narHash, narSize] = hashPath(htSHA256, srcPath);
ValidPathInfo info(makeFixedOutputPath(method, hash, name));
info.narHash = narHash;
info.narSize = narSize;