aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThéophane Hufschmitt <7226587+thufschmitt@users.noreply.github.com>2023-08-08 14:57:45 +0200
committerGitHub <noreply@github.com>2023-08-08 14:57:45 +0200
commitd00fe5f22559efc6f8b4b92eab537b08c0e43dee (patch)
treee82096ae5e78c18f820f568dda1efd5da5e3a570 /src
parent5624777988e0b8368eb019fc8d3e4fc1ff5790e0 (diff)
parentafac001c39aadedcbe52ce45fbde8220834cf13f (diff)
Merge pull request #8805 from tweag/fix-add-to-store-existing
[V2] Fix misread of source if path is already valid
Diffstat (limited to 'src')
-rw-r--r--src/libstore/local-store.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index 40a3bc194..17b4ecc73 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -1196,6 +1196,15 @@ void LocalStore::addToStore(const ValidPathInfo & info, Source & source,
if (checkSigs && pathInfoIsUntrusted(info))
throw Error("cannot add path '%s' because it lacks a signature by a trusted key", printStorePath(info.path));
+ /* In case we are not interested in reading the NAR: discard it. */
+ bool narRead = false;
+ Finally cleanup = [&]() {
+ if (!narRead) {
+ ParseSink sink;
+ parseDump(sink, source);
+ }
+ };
+
addTempRoot(info.path);
if (repair || !isValidPath(info.path)) {
@@ -1220,6 +1229,7 @@ void LocalStore::addToStore(const ValidPathInfo & info, Source & source,
TeeSource wrapperSource { source, hashSink };
+ narRead = true;
restorePath(realPath, wrapperSource);
auto hashResult = hashSink.finish();