aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2021-01-18 14:38:31 +0100
committerEelco Dolstra <edolstra@gmail.com>2021-01-18 14:38:31 +0100
commitea756b3654931f23839aee9f461a8c891c6ffe43 (patch)
tree69f2b18aa5c8ac3db16c513fe371ab4c391d8602
parent1bbc66f8650150898f8d8e3c8c86f3b27802e019 (diff)
--refresh: Imply setting .narinfo disk cache TTL to 0
-rw-r--r--src/libstore/nar-info-disk-cache.cc6
-rw-r--r--src/nix/main.cc5
2 files changed, 8 insertions, 3 deletions
diff --git a/src/libstore/nar-info-disk-cache.cc b/src/libstore/nar-info-disk-cache.cc
index 8541cc51f..1d8d2d57e 100644
--- a/src/libstore/nar-info-disk-cache.cc
+++ b/src/libstore/nar-info-disk-cache.cc
@@ -109,8 +109,10 @@ public:
SQLiteStmt(state->db,
"delete from NARs where ((present = 0 and timestamp < ?) or (present = 1 and timestamp < ?))")
.use()
- (now - settings.ttlNegativeNarInfoCache)
- (now - settings.ttlPositiveNarInfoCache)
+ // Use a minimum TTL to prevent --refresh from
+ // nuking the entire disk cache.
+ (now - std::max(settings.ttlNegativeNarInfoCache.get(), 3600U))
+ (now - std::max(settings.ttlPositiveNarInfoCache.get(), 30 * 24 * 3600U))
.exec();
debug("deleted %d entries from the NAR info disk cache", sqlite3_changes(state->db));
diff --git a/src/nix/main.cc b/src/nix/main.cc
index 418396280..80422bd24 100644
--- a/src/nix/main.cc
+++ b/src/nix/main.cc
@@ -330,8 +330,11 @@ void mainWrapped(int argc, char * * argv)
fileTransferSettings.connectTimeout = 1;
}
- if (args.refresh)
+ if (args.refresh) {
settings.tarballTtl = 0;
+ settings.ttlNegativeNarInfoCache = 0;
+ settings.ttlPositiveNarInfoCache = 0;
+ }
args.command->second->prepare();
args.command->second->run();