aboutsummaryrefslogtreecommitdiff
path: root/src/libstore
diff options
context:
space:
mode:
authorLinus Heckemann <git@sphalerite.org>2022-06-23 14:52:16 -0400
committerLinus Heckemann <git@sphalerite.org>2022-06-23 14:54:25 -0400
commit8cf26385cd8c0e33e36f8d95b9224160424c1c60 (patch)
treebbfacab3906dedacc97e4f61504df1612d31ae8c /src/libstore
parentd533a885465846e7512ff976d3599685c90316eb (diff)
[fixup] handle cache expiration in sqlite query
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/nar-info-disk-cache.cc9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/libstore/nar-info-disk-cache.cc b/src/libstore/nar-info-disk-cache.cc
index 00325fcb8..f4ea739b0 100644
--- a/src/libstore/nar-info-disk-cache.cc
+++ b/src/libstore/nar-info-disk-cache.cc
@@ -101,7 +101,7 @@ public:
"insert or replace into BinaryCaches(url, timestamp, storeDir, wantMassQuery, priority) values (?, ?, ?, ?, ?)");
state->queryCache.create(state->db,
- "select id, timestamp, storeDir, wantMassQuery, priority from BinaryCaches where url = ?");
+ "select id, storeDir, wantMassQuery, priority from BinaryCaches where url = ? and timestamp > ?");
state->insertNAR.create(state->db,
"insert or replace into NARs(cache, hashPart, namePart, url, compression, fileHash, fileSize, narHash, "
@@ -186,14 +186,11 @@ public:
auto i = state->caches.find(uri);
if (i == state->caches.end()) {
- auto queryCache(state->queryCache.use()(uri));
+ auto queryCache(state->queryCache.use()(uri)(time(0) - cacheInfoTtl));
if (!queryCache.next())
return std::nullopt;
- if (queryCache.getInt(1) + cacheInfoTtl < time(0))
- return std::nullopt;
-
state->caches.emplace(uri,
- Cache{(int) queryCache.getInt(0), queryCache.getStr(2), queryCache.getInt(3) != 0, (int) queryCache.getInt(4)});
+ Cache{(int) queryCache.getInt(0), queryCache.getStr(1), queryCache.getInt(2) != 0, (int) queryCache.getInt(3)});
}
auto & cache(getCache(*state, uri));