diff options
author | Damien Elmes <emms@repose.cx> | 2006-06-25 10:51:00 +0000 |
---|---|---|
committer | Damien Elmes <emms@repose.cx> | 2006-06-25 10:51:00 +0000 |
commit | bd115b86296fa6f88b7f945a308cbb89027c68b3 (patch) | |
tree | dc97a386d831e8929ede6cb4bf616a38c7b77db0 | |
parent | 507729e70357d5e9d55c0276907e04fc22223289 (diff) |
cache: rename function, remove obsolete one, only mark dirty if necessary
darcs-hash:20060625105130-4e3e3-9eeb2d394b4324c8cefcfd9aae0a9b8a40971258.gz
-rw-r--r-- | emms-cache.el | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/emms-cache.el b/emms-cache.el index f4385ce..1fc8a48 100644 --- a/emms-cache.el +++ b/emms-cache.el @@ -129,30 +129,29 @@ This is used to cache over emacs sessions.") (load emms-cache-file t nil t) (setq emms-cache-dirty nil)) -(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) - ;; 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)))))) - emms-cache-db) - (setq emms-cache-dirty t) - (message "Updating emms track cache...done")) - (defun emms-cache-sync () - "Remove old entries and update modified files." + "Sync the cache with the data on disc. +Remove non-existent files, and update data for files which have +been modified." (interactive) - (emms-cache-prune) - (emms-cache-refresh)) + (message "Syncing emms track cache...") + (let (removed) + (maphash (lambda (path track) + (when (eq (emms-track-get track 'type) 'file) + ;; if no longer here, remove + (if (not (file-exists-p path)) + (progn + (remhash path emms-cache-db) + (setq removed t)) + (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)))))) + emms-cache-db) + (setq emms-cache-dirty (or emms-cache-dirty removed))) + (message "Syncing emms track cache...done")) (provide 'emms-cache) ;;; emms-cache.el ends here |