summaryrefslogtreecommitdiff
path: root/lisp/url/url-cache.el
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2012-02-06 22:37:56 +0100
committerLars Ingebrigtsen <larsi@gnus.org>2012-02-06 22:37:56 +0100
commit7dd679eb09f65d0a83e14168b005ffc8270e7d05 (patch)
treeee98c391e49decb888d019c85693f554259fac3d /lisp/url/url-cache.el
parent1968bb1b5cc35ba315a741ad27de71e04b6c5aa2 (diff)
downloademacs-7dd679eb09f65d0a83e14168b005ffc8270e7d05.tar.gz
Add extra checks before expiring the URL cache
(url-cache-prune-cache): Check that the directory exists before trying to delete it.
Diffstat (limited to 'lisp/url/url-cache.el')
-rw-r--r--lisp/url/url-cache.el38
1 files changed, 20 insertions, 18 deletions
diff --git a/lisp/url/url-cache.el b/lisp/url/url-cache.el
index 8fec2495675..6559de4deb7 100644
--- a/lisp/url/url-cache.el
+++ b/lisp/url/url-cache.el
@@ -216,24 +216,26 @@ considered \"expired\"."
(let ((current-time (current-time))
(total-files 0)
(deleted-files 0))
- (dolist (file (directory-files (or directory url-cache-directory) t))
- (unless (member (file-name-nondirectory file) '("." ".."))
- (setq total-files (1+ total-files))
- (cond
- ((file-directory-p file)
- (when (url-cache-prune-cache file)
- (setq deleted-files (1+ deleted-files))))
- ((time-less-p
- (time-add
- (nth 5 (file-attributes file))
- (seconds-to-time url-cache-expire-time))
- current-time)
- (delete-file file)
- (setq deleted-files (1+ deleted-files))))))
- (if (< deleted-files total-files)
- nil
- (delete-directory directory)
- t)))
+ (setq directory (or directory url-cache-directory))
+ (when (file-exists-p directory)
+ (dolist (file (directory-files directory t))
+ (unless (member (file-name-nondirectory file) '("." ".."))
+ (setq total-files (1+ total-files))
+ (cond
+ ((file-directory-p file)
+ (when (url-cache-prune-cache file)
+ (setq deleted-files (1+ deleted-files))))
+ ((time-less-p
+ (time-add
+ (nth 5 (file-attributes file))
+ (seconds-to-time url-cache-expire-time))
+ current-time)
+ (delete-file file)
+ (setq deleted-files (1+ deleted-files))))))
+ (if (< deleted-files total-files)
+ nil
+ (delete-directory directory)
+ t))))
(provide 'url-cache)