about summary refs log tree commit diff
path: root/src/libstore/binary-cache-store.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2016-04-15T13·25+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2016-04-15T13·39+0200
commita7d8eaba540ce272bc4fc19afdeae177a3b086d9 (patch)
tree9ddb9fe60a9e5d35869e07c65f90cf55c7b8f5af /src/libstore/binary-cache-store.cc
parentd1b0909894a302540f979d904dd378af1cad620c (diff)
BinaryCacheStore: Do negative caching of .narinfo lookups
Diffstat (limited to 'src/libstore/binary-cache-store.cc')
-rw-r--r--src/libstore/binary-cache-store.cc12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/libstore/binary-cache-store.cc b/src/libstore/binary-cache-store.cc
index 7c8fdfd0811c..7016eedfa701 100644
--- a/src/libstore/binary-cache-store.cc
+++ b/src/libstore/binary-cache-store.cc
@@ -114,14 +114,22 @@ NarInfo BinaryCacheStore::readNarInfo(const Path & storePath)
         auto res = state_->narInfoCache.get(storePath);
         if (res) {
             stats.narInfoReadAverted++;
+            if (!*res)
+                throw InvalidPath(format("path ‘%s’ is not valid") % storePath);
             return **res;
         }
     }
 
     auto narInfoFile = narInfoFileFor(storePath);
     auto data = getFile(narInfoFile);
-    if (!data)
+    if (!data) {
+        stats.narInfoMissing++;
+        auto state_(state.lock());
+        state_->narInfoCache.upsert(storePath, 0);
+        stats.narInfoCacheSize = state_->narInfoCache.size();
         throw InvalidPath(format("path ‘%s’ is not valid") % storePath);
+    }
+
     auto narInfo = make_ref<NarInfo>(*data, narInfoFile);
     if (narInfo->path != storePath)
         throw Error(format("NAR info file for store path ‘%1%’ does not match ‘%2%’") % narInfo->path % storePath);
@@ -149,7 +157,7 @@ bool BinaryCacheStore::isValidPath(const Path & storePath)
         auto res = state_->narInfoCache.get(storePath);
         if (res) {
             stats.narInfoReadAverted++;
-            return true;
+            return *res != 0;
         }
     }