From 3eb4ae3b82b7a363d682137dba5d1cd42909eeb2 Mon Sep 17 00:00:00 2001 From: eriedaberrie Date: Tue, 12 Nov 2024 01:21:16 -0800 Subject: [PATCH] feat: sync-music: don't use cue track files if that file doesn't exist --- sync-music/sync-music.lisp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/sync-music/sync-music.lisp b/sync-music/sync-music.lisp index 660927b..a7201a9 100644 --- a/sync-music/sync-music.lisp +++ b/sync-music/sync-music.lisp @@ -20,7 +20,7 @@ if the file should not be copied." :origin origin :target (pathname-normalize-unicode (make-pathname :name (pathname-name origin) - :type type + :type (string-downcase type) :defaults target))))) (defun get-cue-copy-actions (origin origin-files target &optional (test #'string-equal)) @@ -52,6 +52,12 @@ extension equality." :for track-number :from 1 :upto track-count :for track-number-str := (format nil "~2,'0D" track-number) :for track := (libcue:cd-get-track cd track-number) + :for origin-file-name := (let* ((raw-file (libcue:track-get-file-name track)) + (dot (position #\. raw-file :from-end t))) + (subseq raw-file 0 dot)) + :for origin-file := (make-pathname :name origin-file-name + :type "flac" + :defaults origin) :for track-rem := (libcue:track-get-rem track) :for track-cd-text := (libcue:track-get-cd-text track) :for track-date := (or (libcue:ensure-nonempty @@ -67,12 +73,6 @@ extension equality." :for track-genre := (or (libcue:ensure-nonempty (libcue:get-cd-text :genre track-cd-text)) album-genre) - :for origin-file-name := (let* ((raw-file (libcue:track-get-file-name track)) - (dot (position #\. raw-file :from-end t))) - (subseq raw-file 0 dot)) - :for origin-file := (make-pathname :name origin-file-name - :type "flac" - :defaults origin) :for metadata := (let ((metadata)) (flet ((add-metadata (field value) (when value @@ -105,6 +105,8 @@ extension equality." :length (libcue:ensure-nonempty (libcue:track-get-length track)) :metadata metadata) + :unless (some (lambda (p) (equal p origin-file)) origin-files) + :return nil :do (fset:adjoinf actions current-action) :finally (return actions)))))))