Function: url-cache-prune-cache

url-cache-prune-cache is an autoloaded and byte-compiled function defined in url-cache.el.gz.

Signature

(url-cache-prune-cache &optional DIRECTORY)

Documentation

Remove all expired files from the cache.

url-cache-expire-time says how old a file has to be to be considered "expired".

Source Code

;; Defined in /usr/src/emacs/lisp/url/url-cache.el.gz
(defun url-cache-prune-cache (&optional directory)
  "Remove all expired files from the cache.
`url-cache-expire-time' says how old a file has to be to be
considered \"expired\"."
  (let ((now (current-time))
	(total-files 0)
	(deleted-files 0))
    (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
	      (file-attribute-modification-time (file-attributes file))
	      url-cache-expire-time)
	     now)
	    (delete-file file)
	    (setq deleted-files (1+ deleted-files))))))
      (if (< deleted-files total-files)
	  nil
	(delete-directory directory)
	t))))