feat: sync-music: don't use cue track files if that file doesn't exist

This commit is contained in:
eriedaberrie 2024-11-12 01:21:16 -08:00
parent cea9a46872
commit 364c984620

View file

@ -20,7 +20,7 @@ if the file should not be copied."
:origin origin :origin origin
:target (pathname-normalize-unicode :target (pathname-normalize-unicode
(make-pathname :name (pathname-name origin) (make-pathname :name (pathname-name origin)
:type type :type (string-downcase type)
:defaults target))))) :defaults target)))))
(defun get-cue-copy-actions (origin origin-files target &optional (test #'string-equal)) (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 :from 1 :upto track-count
:for track-number-str := (format nil "~2,'0D" track-number) :for track-number-str := (format nil "~2,'0D" track-number)
:for track := (libcue:cd-get-track cd 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-rem := (libcue:track-get-rem track)
:for track-cd-text := (libcue:track-get-cd-text track) :for track-cd-text := (libcue:track-get-cd-text track)
:for track-date := (or (libcue:ensure-nonempty :for track-date := (or (libcue:ensure-nonempty
@ -67,12 +73,6 @@ extension equality."
:for track-genre := (or (libcue:ensure-nonempty :for track-genre := (or (libcue:ensure-nonempty
(libcue:get-cd-text :genre track-cd-text)) (libcue:get-cd-text :genre track-cd-text))
album-genre) 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)) :for metadata := (let ((metadata))
(flet ((add-metadata (field value) (flet ((add-metadata (field value)
(when value (when value
@ -105,6 +105,8 @@ extension equality."
:length (libcue:ensure-nonempty :length (libcue:ensure-nonempty
(libcue:track-get-length track)) (libcue:track-get-length track))
:metadata metadata) :metadata metadata)
:unless (uiop:file-exists-p origin-file)
:return nil
:do (fset:adjoinf actions current-action) :do (fset:adjoinf actions current-action)
:finally (return actions))))))) :finally (return actions)))))))