diff options
| author | leuven65 <31041544+leuven65@users.noreply.github.com> | 2025-02-12 21:59:08 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-12 22:59:08 +0200 |
| commit | ce6e637cc2b9d4fdffdbdc1c7b8d7e2ac388515b (patch) | |
| tree | 75c3746017f21bbe59bf650ec3ea212fad54fa30 /projectile.el | |
| parent | 48d0a30137dc4dfecc261e66f2a5f75156232d85 (diff) | |
[#1926] Don't create any cache file when persistent caching is not enabled (#1929)
Diffstat (limited to 'projectile.el')
| -rw-r--r-- | projectile.el | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/projectile.el b/projectile.el index 72bc32c..8cf97ba 100644 --- a/projectile.el +++ b/projectile.el @@ -1080,6 +1080,9 @@ A wrapper around `file-exists-p' with additional caching support." (run-with-timer 10 nil 'projectile-file-exists-cache-cleanup))) (equal value 'found))))) +(defsubst projectile-caching-persistent-p () + (eq projectile-enable-caching 'persistent)) + ;;;###autoload (defun projectile-invalidate-cache (prompt) "Remove the current project's files from `projectile-projects-cache'. @@ -1098,7 +1101,7 @@ to invalidate." (remhash project-root projectile-projects-cache) (remhash project-root projectile-projects-cache-time) ;; reset the project's cache file - (when (eq projectile-enable-caching 'persistent) + (when (projectile-caching-persistent-p) ;; TODO: Perhaps it's better to delete the cache file in such cases? (projectile-serialize nil (projectile-project-cache-file project-root))) (when projectile-verbose @@ -1119,7 +1122,7 @@ to invalidate." The cache is created both in memory and on the hard drive." (puthash project files projectile-projects-cache) (puthash project (projectile-time-seconds) projectile-projects-cache-time) - (when (eq projectile-enable-caching 'persistent) + (when (projectile-caching-persistent-p) (projectile-serialize files (projectile-project-cache-file project)))) (defun projectile-load-project-cache (project-root) @@ -1140,7 +1143,8 @@ The cache is created both in memory and on the hard drive." (if (projectile-file-cached-p file project-root) (progn (puthash project-root (remove file project-cache) projectile-projects-cache) - (projectile-serialize project-cache (projectile-project-cache-file project-root)) + (when (projectile-caching-persistent-p) + (projectile-serialize project-cache (projectile-project-cache-file project-root))) (when projectile-verbose (message "%s removed from cache" file))) (error "%s is not in the cache" file)))) @@ -1178,10 +1182,11 @@ The cache is created both in memory and on the hard drive." (puthash current-project project-files projectile-projects-cache) ;; we serialize the cache with an idle time to avoid freezing the UI ;; immediately after the new file was created - (run-with-idle-timer - 30 - nil - 'projectile-serialize project-files cache-file)) + (when (projectile-caching-persistent-p) + (run-with-idle-timer + 30 + nil + 'projectile-serialize project-files cache-file))) (message "File %s added to project %s cache." (propertize current-file 'face 'font-lock-keyword-face) (propertize current-project 'face 'font-lock-keyword-face))))))) |
