diff options
author | lucas <lucas> | 2006-06-25 09:59:00 +0000 |
---|---|---|
committer | lucas <mwolson@gnu.org> | 2006-06-25 09:59:00 +0000 |
commit | 507729e70357d5e9d55c0276907e04fc22223289 (patch) | |
tree | cfca3565166d59c8e76e90e22588a64dc298b59f | |
parent | 3672c9ee39f0d15815a79e69dc1a52a9cfbb8b44 (diff) |
emms-cache.el: Move the pruning code inside emms-cache-refresh.
darcs-hash:20060625095901-4f952-96d60b326e8e09587e2d92cffc838f00864241a4.gz
-rw-r--r-- | emms-cache.el | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/emms-cache.el b/emms-cache.el index df9bd7f..f4385ce 100644 --- a/emms-cache.el +++ b/emms-cache.el @@ -129,32 +129,23 @@ This is used to cache over emacs sessions.") (load emms-cache-file t nil t) (setq emms-cache-dirty nil)) -(defun emms-cache-prune () - "Remove invalid entries from the cache." - ;; FIXME: at the moment, only supports files - (interactive) - (message "Pruning emms track cache...") - (maphash (lambda (path track) - (when (eq (emms-track-get track 'type) 'file) - (unless (file-exists-p path) - (remhash path emms-cache-db)))) - emms-cache-db) - (setq emms-cache-dirty t) - (message "Pruning emms track cache...done")) - (defun emms-cache-refresh () "Update entries in the cache where the file is newer." (interactive) (message "Updating emms track cache...") (maphash (lambda (path track) (when (eq (emms-track-get track 'type) 'file) - (let ((file-mtime (emms-info-track-file-mtime track)) - (info-mtime (emms-track-get track 'info-mtime))) - (when (or (not info-mtime) + ;; if no longer here, remove + (if (not (file-exists-p path)) + (remhash path emms-cache-db) + (let ((file-mtime (emms-info-track-file-mtime track)) + (info-mtime (emms-track-get track 'info-mtime))) + (when (or (not info-mtime) (emms-time-less-p info-mtime file-mtime)) - (run-hook-with-args 'emms-info-functions track))))) + (run-hook-with-args 'emms-info-functions track)))))) emms-cache-db) + (setq emms-cache-dirty t) (message "Updating emms track cache...done")) (defun emms-cache-sync () |