From 80f359922a3ad67e6e807bf192798ff0ff37136a Mon Sep 17 00:00:00 2001 From: kaoru Date: Thu, 28 May 2009 10:49:50 +0000 Subject: [PATCH] 2009-05-26 Vitaly Mayatskikh * modb-standard.el (modb-standard-cleanup-stale-entities): New function, Remove stale entities from elmo's cache. --- elmo/ChangeLog | 3 +++ elmo/modb-standard.el | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/elmo/ChangeLog b/elmo/ChangeLog index 9eda801..2409a29 100644 --- a/elmo/ChangeLog +++ b/elmo/ChangeLog @@ -5,6 +5,9 @@ * elmo-mime.el (elmo-mime-entity-display): Fix Emacs crash in mime-view when displaying malformed base64 attach. + * modb-standard.el (modb-standard-cleanup-stale-entities): New + function, Remove stale entities from elmo's cache. + 2009-05-26 TAKAHASHI Kaoru * elmo-version.el (elmo-version): Up to 2.15.7. diff --git a/elmo/modb-standard.el b/elmo/modb-standard.el index 1ecfcd6..dc413c8 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) -- 1.7.10.4