aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Leech-Pepin <jonathan.leechpepin@gmail.com>2014-11-19 09:19:22 -0500
committerJonathan Leech-Pepin <jonathan.leechpepin@gmail.com>2014-11-19 09:19:22 -0500
commitbb4d8791f6cafeb0b87aa512aab2f0a97e8c0d3d (patch)
tree19ab6a3b97edc60857154192ae2272b358e24fdd
parent7e3685bf944378c49738de2ee2c685af785806b6 (diff)
Fix cache invalidation to behave properly.
Use `delete-file` rather than simply setting cache to `nil`. nil is still a valid cache value which can cause reinitialization to fail. Fix bug with nil funcall.
-rw-r--r--sx-cache.el17
1 files changed, 11 insertions, 6 deletions
diff --git a/sx-cache.el b/sx-cache.el
index a564a53..b668213 100644
--- a/sx-cache.el
+++ b/sx-cache.el
@@ -73,23 +73,28 @@ DATA will be written as returned by `prin1'."
VARS is a list of variables to unbind to ensure cache is cleared.
If INIT-METHOD is defined, call it after all invalidation to
re-initialize the cache."
- (sx-cache-set cache nil)
+ (let ((file (sx-cache-get-file-name cache)))
+ (delete-file file))
(mapc #'makunbound vars)
- (funcall init-method))
+ (when init-method
+ (funcall init-method)))
(defun sx-cache-invalidate-all (&optional save-auth)
"Invalidate all caches using `sx-cache--invalidate'.
Afterwards reinitialize caches using `sx-initialize'.
+Note: This will also remove read/unread status of questions as well
+as delete the list of hidden questions.
+
If SAVE-AUTH is non-nil, do not clear AUTH cache."
- (let ((caches (let ((default-directory sx-cache-directory))
- (file-expand-wildcards "*.el"))))
+ (let* ((default-directory sx-cache-directory)
+ (caches (file-expand-wildcards "*.el")))
(when save-auth
(setq caches (cl-remove-if (lambda (x)
- (string= x "auth.el")) caches)))
+ (string= x "auth.el")) caches)))
(lwarn 'stack-mode :debug "Invalidating: %S" caches)
- (mapc #'sx-cache--invalidate caches)
+ (mapc #'delete-file caches)
(sx-initialize 'force)))
(provide 'sx-cache)