BinaryCacheStore::isValidPath(): Use .narinfo cache

If a path is in the .narinfo cache, obviously it's valid.
This commit is contained in:
Eelco Dolstra 2016-03-14 12:29:32 +01:00
parent 674c5ff64f
commit e7c76f7274

View file

@ -141,6 +141,15 @@ NarInfo BinaryCacheStore::readNarInfo(const Path & storePath)
bool BinaryCacheStore::isValidPath(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 // FIXME: this only checks whether a .narinfo with a matching hash
// part exists. So f4kb...-foo matches f4kb...-bar, even // part exists. So f4kb...-foo matches f4kb...-bar, even
// though they shouldn't. Not easily fixed. // though they shouldn't. Not easily fixed.