aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2020-03-13 12:23:19 +0100
committerEelco Dolstra <edolstra@gmail.com>2020-03-13 13:15:51 +0100
commitb816515f613b7013ba0d5489841568b8f666f224 (patch)
treee8b41a796c1eea5613aa531538815db795e92fed /src
parentd048577909e383439c2549e849c5c2f2016c997e (diff)
Fix ca-references feature check
Fixes #3406.
Diffstat (limited to 'src')
-rw-r--r--src/libstore/local-store.cc14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index c5929a41c..cd2e86f29 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -1004,16 +1004,18 @@ void LocalStore::addToStore(const ValidPathInfo & info, Source & source,
deletePath(realPath);
+ if (info.ca != "" &&
+ !((hasPrefix(info.ca, "text:") && !info.references.count(info.path))
+ || info.references.empty()))
+ settings.requireExperimentalFeature("ca-references");
+
/* While restoring the path from the NAR, compute the hash
of the NAR. */
std::unique_ptr<AbstractHashSink> hashSink;
- if (info.ca == "")
+ if (info.ca == "" || !info.references.count(info.path))
hashSink = std::make_unique<HashSink>(htSHA256);
- else {
- if (!info.references.empty())
- settings.requireExperimentalFeature("ca-references");
+ else
hashSink = std::make_unique<HashModuloSink>(htSHA256, storePathToHash(printStorePath(info.path)));
- }
LambdaSource wrapperSource([&](unsigned char * data, size_t len) -> size_t {
size_t n = source.read(data, len);
@@ -1268,7 +1270,7 @@ bool LocalStore::verifyStore(bool checkContents, RepairFlag repair)
printMsg(lvlTalkative, "checking contents of '%s'", printStorePath(i));
std::unique_ptr<AbstractHashSink> hashSink;
- if (info->ca == "")
+ if (info->ca == "" || !info->references.count(info->path))
hashSink = std::make_unique<HashSink>(info->narHash.type);
else
hashSink = std::make_unique<HashModuloSink>(info->narHash.type, storePathToHash(printStorePath(info->path)));