From 43b8e96d30fa2b4e5f2f5144dc905c2d944a4e15 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 13 Jul 2020 20:17:00 +0200 Subject: [PATCH] Fix 'nix verify --all' on a binary cache (cached case) --- src/libstore/store-api.cc | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index bc3fafa35..5554befa4 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -351,6 +351,14 @@ ref Store::queryPathInfo(const StorePath & storePath) } +static bool goodStorePath(const StorePath & expected, const StorePath & actual) +{ + return + expected.hashPart() == actual.hashPart() + && (expected.name() == Store::MissingName || expected.name() == actual.name()); +} + + void Store::queryPathInfo(const StorePath & storePath, Callback> callback) noexcept { @@ -378,7 +386,7 @@ void Store::queryPathInfo(const StorePath & storePath, state_->pathInfoCache.upsert(hashPart, res.first == NarInfoDiskCache::oInvalid ? PathInfoCacheValue{} : PathInfoCacheValue{ .value = res.second }); if (res.first == NarInfoDiskCache::oInvalid || - res.second->path != storePath) + !goodStorePath(storePath, res.second->path)) throw InvalidPath("path '%s' is not valid", printStorePath(storePath)); } return callback(ref(res.second)); @@ -405,11 +413,7 @@ void Store::queryPathInfo(const StorePath & storePath, auto storePath = parseStorePath(storePathS); - if (!info - || info->path.hashPart() != storePath.hashPart() - || (storePath.name() != MissingName && info->path.name() != storePath.name()) - ) - { + if (!info || !goodStorePath(storePath, info->path)); { stats.narInfoMissing++; throw InvalidPath("path '%s' is not valid", storePathS); }