From: vitaly Date: Tue, 26 May 2009 15:02:47 +0000 (+0000) Subject: Remove stale entities X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=14c5ba25e75a2377a6f051f0354caa741f3a3abd;p=elisp%2Fwanderlust.git Remove stale entities Wl doesn't remove old entities from elmo cache, which are not referenced by any live message any more. This silently eats your disk space.... --- diff --git a/elmo/modb-standard.el b/elmo/modb-standard.el index 1ecfcd6..f268c3a 100644 --- a/elmo/modb-standard.el +++ b/elmo/modb-standard.el @@ -247,6 +247,23 @@ entities)) (ignore-errors (delete-file filename))))) +(defun modb-standard-cleanup-stale-entities (modb path) + (message "Removing stale entities...") + (let* ((entity-regex + (concat "^" modb-standard-entity-filename "-\\([0-9]+\\)")) + (entities (elmo-uniq-list + (mapcar + #'(lambda (x) (/ x modb-standard-divide-number)) + (modb-standard-number-list-internal modb)))) + (files (mapcar #'(lambda(x) + (when (string-match entity-regex x) + (string-to-int (match-string 1 x)))) + (directory-files path nil entity-regex)))) + (dolist (entity (car (elmo-list-diff-nonsortable files entities))) + (ignore-errors (delete-file + (expand-file-name + (modb-standard-entity-filename entity) path)))))) + (defun modb-standard-save-entity (modb path) (let ((modified (modb-generic-message-modified-internal modb))) (cond ((listp modified) @@ -259,7 +276,8 @@ (dolist (section sections) (modb-standard-save-entity-1 modb path section)))) (modified - (modb-standard-save-entity-1 modb path))))) + (modb-standard-save-entity-1 modb path)))) + (modb-standard-cleanup-stale-entities modb path)) ;;; Implement ;;