branch: elpa/projectile commit ce6e637cc2b9d4fdffdbdc1c7b8d7e2ac388515b Author: leuven65 <31041544+leuve...@users.noreply.github.com> Commit: GitHub <nore...@github.com>
[#1926] Don't create any cache file when persistent caching is not enabled (#1929) --- projectile.el | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/projectile.el b/projectile.el index 72bc32cf48..8cf97baf43 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)))))))