aboutsummaryrefslogtreecommitdiff
path: root/projectile.el
diff options
context:
space:
mode:
authorBozhidar Batsov <bozhidar@toptal.com>2026-04-27 01:27:35 +0000
committerBozhidar Batsov <bozhidar@toptal.com>2026-04-27 01:27:35 +0000
commita55eeb2b1821c5252a5ea3d8c7c79728a42763fe (patch)
tree9d31b39e0aa4a9821232eceb790d4894c13d77ba /projectile.el
parent67c18e26fe68552a273b7794451ce757cc3afe9a (diff)
Seed cache time when loading the project file cache from disk
Without this, `projectile-files-cache-expire' combined with persistent caching ended up re-reading the cache file from disk on every call to `projectile-project-files' and never reindexing: the TTL check at the top of `projectile-project-files' evicts the in-memory entry whenever its cache time is missing, and `projectile-load-project-cache' was populating only `projectile-projects-cache' on disk loads. Use the cache file's mtime as the recorded time, so the TTL check sees a real age and reindexing happens when (and only when) the data is actually stale.
Diffstat (limited to 'projectile.el')
-rw-r--r--projectile.el10
1 files changed, 10 insertions, 0 deletions
diff --git a/projectile.el b/projectile.el
index c4c0154..977860e 100644
--- a/projectile.el
+++ b/projectile.el
@@ -1221,6 +1221,16 @@ The cache is created both in memory and on the hard drive."
(when (file-exists-p cache-file)
(when-let* ((data (projectile-unserialize cache-file)))
(puthash project-root data projectile-projects-cache)
+ ;; Seed the cache time from the file's mtime so the TTL check in
+ ;; `projectile-project-files' can decide whether the loaded data is
+ ;; already stale, and so the in-memory entry isn't evicted on the
+ ;; next call just because no time was recorded.
+ (puthash project-root
+ (time-convert
+ (file-attribute-modification-time
+ (file-attributes cache-file))
+ 'integer)
+ projectile-projects-cache-time)
data))))
;;;###autoload