fix: sync-music: ensure output file names are valid on Android

This commit is contained in:
eriedaberrie 2024-11-07 15:45:11 -08:00
parent 1a714ac77a
commit 5f61ca0280
2 changed files with 9 additions and 4 deletions

View file

@ -84,10 +84,12 @@ Return the action if it exists, or NIL if the file should not be copied."
data-raw) data-raw)
:for metadata-filtered := (delete-if (compose #'emptyp #'cdr) metadata) :for metadata-filtered := (delete-if (compose #'emptyp #'cdr) metadata)
:for previous-action := nil :then current-action :for previous-action := nil :then current-action
:for output-file-name := (substitute #\! #\/ (format nil :for output-file-name := (ppcre:regex-replace-all *invalid-char-scanner*
"~A - ~A" (format nil
track-number "~A - ~A"
track-title)) track-number
track-title)
"!!!")
:for current-action := (make-copy-flac-action :for current-action := (make-copy-flac-action
:origin origin-file :origin origin-file
:target (pathname-normalize-unicode :target (pathname-normalize-unicode

View file

@ -21,6 +21,9 @@
(defparameter *timestamp-scanner* (ppcre:create-scanner "^(\\d+):(\\d{2})\\.(\\d{2})$") (defparameter *timestamp-scanner* (ppcre:create-scanner "^(\\d+):(\\d{2})\\.(\\d{2})$")
"Scan for a cuetools position.") "Scan for a cuetools position.")
(defparameter *invalid-char-scanner* (ppcre:create-scanner "[\"*/:<>?\\\\|]")
"Scan for any characters not allowed in an Android/NTFS file name.")
(defun maybe-normalize-unicode (s) (defun maybe-normalize-unicode (s)
(if (stringp s) (uax-15:normalize s :nfc) s)) (if (stringp s) (uax-15:normalize s :nfc) s))