aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBozhidar Batsov <bozhidar@toptal.com>2026-04-27 07:50:40 +0000
committerBozhidar Batsov <bozhidar@toptal.com>2026-04-27 07:50:40 +0000
commitd8bbeedd275cea4765555c731b265ce7757ad9e5 (patch)
tree60337295dafc9fb42f8364b7774e063bc1bcebb3
parentfc8559850228f54efbc7ee4ea56b2e376cec5b04 (diff)
Delete cache file in projectile-invalidate-cache
Previously the persistent invalidate path called `(projectile-serialize nil ...)', leaving a four-byte file containing the literal "nil" on disk. Resolving the long-standing TODO: just delete the file when invalidating, so the on-disk state matches the intent of the command (and so an orphaned cache file isn't left behind on uninstall).
-rw-r--r--CHANGELOG.md1
-rw-r--r--projectile.el5
2 files changed, 4 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 298727c..b40474d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -45,6 +45,7 @@
* Fix `projectile-load-project-cache` not recording a cache time, which combined with `projectile-files-cache-expire` made the TTL check immediately re-evict freshly loaded data — every call ended up re-reading the cache file from disk and the data was never reindexed. The cache file's mtime is now used to seed `projectile-projects-cache-time`.
* Fix `projectile-load-project-cache` storing nil in cache on corrupt/empty cache files, preventing future reload attempts.
* Fix `projectile-purge-dir-from-cache` only updating the in-memory cache; with persistent caching the purged directory's files would reappear on the next session. The on-disk cache is now updated as well, matching the behavior of `projectile-purge-file-from-cache`.
+* `projectile-invalidate-cache` now deletes the persistent cache file instead of overwriting it with a serialized `nil`.
* Fix `projectile--cmake-command-presets` using `mapcar` instead of `mapcan`, producing nested lists for included presets.
* Fix `projectile--eat` ignoring the `new-process` argument when generating buffer names.
* Fix `projectile-check-vcs-status` hanging indefinitely by adding a 30-second timeout to its busy-wait loop.
diff --git a/projectile.el b/projectile.el
index f81133d..773dae1 100644
--- a/projectile.el
+++ b/projectile.el
@@ -1181,8 +1181,9 @@ argument)."
(remhash project-root projectile--dirconfig-cache)
;; reset the project's cache file
(when (projectile-persistent-cache-p)
- ;; TODO: Perhaps it's better to delete the cache file in such cases?
- (projectile-serialize nil (projectile-project-cache-file project-root)))
+ (let ((cache-file (projectile-project-cache-file project-root)))
+ (when (file-exists-p cache-file)
+ (delete-file cache-file))))
(when projectile-verbose
(message "Invalidated Projectile cache for %s."
(propertize project-root 'face 'font-lock-keyword-face))))