aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetteri Hintsanen <petterih@iki.fi>2021-03-11 20:53:11 +0200
committerPetteri Hintsanen <petterih@iki.fi>2021-04-30 00:39:35 +0300
commit74429d5abfc8399af4cb058eb8e0bad6c5f9be27 (patch)
treec87660552f542f5899db611a5b6b52ac749fc7f6
parentd56d7053a08beab4c4cf047628f6c417bfccb2f2 (diff)
Make it possible to force-update Emms cache
Add a prefix argument to emms-cache-sync that will unconditionally update all tracks in Emms cache.
-rw-r--r--emms-cache.el17
-rw-r--r--emms-info.el14
2 files changed, 17 insertions, 14 deletions
diff --git a/emms-cache.el b/emms-cache.el
index 766af8c..72d0097 100644
--- a/emms-cache.el
+++ b/emms-cache.el
@@ -155,12 +155,12 @@ This is used to cache over emacs sessions.")
(load emms-cache-file t nil t)
(setq emms-cache-dirty nil))
-(defun emms-cache-sync ()
+(defun emms-cache-sync (arg)
"Sync the cache with the data on disc.
Remove non-existent files, and update data for files which have
-been modified."
- (interactive)
- (message "Syncing emms track cache...")
+been modified. With prefix argument, update data for all files
+regardless of whether they have been modified or not."
+ (interactive "P")
(let (removed)
(maphash (lambda (path track)
(when (eq (emms-track-get track 'type) 'file)
@@ -172,13 +172,12 @@ been modified."
(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-time-less-p info-mtime file-mtime)
+ arg)
+ (emms-info-initialize-track track arg))))))
emms-cache-db)
(when removed
- (setq emms-cache-dirty t)))
- (message "Syncing emms track cache...done"))
+ (setq emms-cache-dirty t))))
(defun emms-cache-reset ()
"Reset the cache."
diff --git a/emms-info.el b/emms-info.el
index a120236..b7a6537 100644
--- a/emms-info.el
+++ b/emms-info.el
@@ -75,15 +75,18 @@ Each is called with a track as argument."
(defvar emms-info-asynchronous-tracks 0
"Number of tracks we're waiting for to be done.")
-(defun emms-info-initialize-track (track)
+(defun emms-info-initialize-track (track &optional force)
"Initialize TRACK with emms-info information.
+Update TRACK information if it is new or has been modified since
+last update, or if FORCE is non-nil.
+
This is a suitable value for `emms-track-initialize-functions'."
(if (not emms-info-asynchronously)
- (emms-info-really-initialize-track track)
+ (emms-info-really-initialize-track track force)
(setq emms-info-asynchronous-tracks (1+ emms-info-asynchronous-tracks))
- (emms-later-do 'emms-info-really-initialize-track track)))
+ (emms-later-do 'emms-info-really-initialize-track track force)))
-(defun emms-info-really-initialize-track (track)
+(defun emms-info-really-initialize-track (track &optional force)
"Really initialize TRACK.
Return t when the track got changed."
(let ((file-mtime (when emms-info-auto-update
@@ -93,7 +96,8 @@ Return t when the track got changed."
;; if the file's been modified or is new
(when (or (not file-mtime)
(not info-mtime)
- (emms-time-less-p info-mtime file-mtime))
+ (emms-time-less-p info-mtime file-mtime)
+ force)
(run-hook-with-args 'emms-info-functions track)
;; not set by info functions
(when file-mtime