emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/emms 74429d5 6/7: Make it possible to force-update Emms


From: ELPA Syncer
Subject: [elpa] externals/emms 74429d5 6/7: Make it possible to force-update Emms cache
Date: Mon, 3 May 2021 09:57:15 -0400 (EDT)

branch: externals/emms
commit 74429d5abfc8399af4cb058eb8e0bad6c5f9be27
Author: Petteri Hintsanen <petterih@iki.fi>
Commit: Petteri Hintsanen <petterih@iki.fi>

    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.
---
 emms-cache.el | 17 ++++++++---------
 emms-info.el  | 14 +++++++++-----
 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]