diff options
Diffstat (limited to 'src/libstore/binary-cache-store.cc')
-rw-r--r-- | src/libstore/binary-cache-store.cc | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/src/libstore/binary-cache-store.cc b/src/libstore/binary-cache-store.cc index 5ded16d028b0..473a0b2614bb 100644 --- a/src/libstore/binary-cache-store.cc +++ b/src/libstore/binary-cache-store.cc @@ -126,8 +126,8 @@ NarInfo BinaryCacheStore::readNarInfo(const Path & storePath) stats.narInfoRead++; if (publicKeys) { - if (!narInfo->checkSignature(*publicKeys)) - throw Error(format("invalid signature on NAR info file ‘%1%’") % narInfoFile); + if (!narInfo->checkSignatures(*publicKeys)) + throw Error(format("no good signature on NAR info file ‘%1%’") % narInfoFile); } { @@ -141,16 +141,23 @@ NarInfo BinaryCacheStore::readNarInfo(const Path & storePath) bool BinaryCacheStore::isValidPath(const Path & storePath) { + { + auto state_(state.lock()); + auto res = state_->narInfoCache.get(storePath); + if (res) { + stats.narInfoReadAverted++; + return true; + } + } + // FIXME: this only checks whether a .narinfo with a matching hash // part exists. So ‘f4kb...-foo’ matches ‘f4kb...-bar’, even // though they shouldn't. Not easily fixed. return fileExists(narInfoFileFor(storePath)); } -void BinaryCacheStore::exportPath(const Path & storePath, bool sign, Sink & sink) +void BinaryCacheStore::narFromPath(const Path & storePath, Sink & sink) { - assert(!sign); - auto res = readNarInfo(storePath); auto nar = getFile(res.url); @@ -174,6 +181,15 @@ void BinaryCacheStore::exportPath(const Path & storePath, bool sign, Sink & sink assert(nar.size() % 8 == 0); sink((unsigned char *) nar.c_str(), nar.size()); +} + +void BinaryCacheStore::exportPath(const Path & storePath, bool sign, Sink & sink) +{ + assert(!sign); + + auto res = readNarInfo(storePath); + + narFromPath(storePath, sink); // FIXME: check integrity of NAR. |