small bug fixes
This commit is contained in:
+29
-22
@@ -18,7 +18,7 @@
|
||||
(define (audio-manager music-path opus-path #:log-level [log-level 'debug])
|
||||
(let* ((ini-config-file (build-path music-path ".audio-manager.ini"))
|
||||
(ini (file->ini ini-config-file))
|
||||
(mail-oke (check-mail-config))
|
||||
(mail-oke (check-mail-config ini))
|
||||
(report-flacs-with-id3 "FLAC files with id3 tags\n\n")
|
||||
(report-flac "")
|
||||
(report-opus "")
|
||||
@@ -42,7 +42,7 @@
|
||||
(processed-kind (make-hash))
|
||||
(base-rate (ini-get ini 'flac 'max-khz 48000))
|
||||
(dirs-logged -1)
|
||||
(known-audio-exts '(mp3 flac opus mp4 mp4a mpg ape wav))
|
||||
(known-audio-exts '(mp3 flac opus mp4 m4a mpg ape wav))
|
||||
(known-exts (append known-audio-exts
|
||||
'(jpg jpeg png pdf)))
|
||||
(unknown-exts '())
|
||||
@@ -60,12 +60,22 @@
|
||||
(eq? state 'new)))))
|
||||
|
||||
(define (needs-copying? info)
|
||||
(and (eq? (hash-ref info 'type #f) 'file)
|
||||
(not (eq? (hash-ref info 'file-db #f) 'deleted))
|
||||
(let ((path-part (get-path-part info)))
|
||||
(if (eq? path-part #f)
|
||||
#f
|
||||
(not (file-exists? (build-path opus-path path-part)))))))
|
||||
(let ((state (hash-ref info 'file-db #f)))
|
||||
(and (eq? (hash-ref info 'type #f) 'file)
|
||||
(not (eq? state 'deleted))
|
||||
(not-hidden? path)
|
||||
(let ((path-part (get-path-part info)))
|
||||
(if (eq? path-part #f)
|
||||
#f
|
||||
(if (and (eq? state 'unchanged)
|
||||
(file-exists? (build-path opus-path path-part)))
|
||||
#f
|
||||
#t)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(define (deleted? info)
|
||||
(eq? (hash-ref info 'file-db #f) 'deleted))
|
||||
@@ -84,18 +94,17 @@
|
||||
(eq? (hash-ref info 'ext) 'flac)
|
||||
(eq? (hash-ref info 'sniffed #f) 'mp3)))
|
||||
|
||||
(define (presumed-flac? info)
|
||||
(and (eq? (hash-ref info 'type) 'file)
|
||||
(eq? (hash-ref info 'ext) 'flac)))
|
||||
|
||||
(define (flac? path info)
|
||||
(when (eq? (hash-ref info 'type) 'file)
|
||||
(when (presumed-flac? info)
|
||||
(let ((s (hash-ref info 'sniffed #f)))
|
||||
(when (eq? s #f)
|
||||
(hash-set! info 'sniffed (audio-sniff-format path))
|
||||
)))
|
||||
(and
|
||||
(eq? (hash-ref info 'type) 'file)
|
||||
(eq? (hash-ref info 'ext) 'flac)
|
||||
(eq? (hash-ref info 'sniffed) 'flac)
|
||||
)
|
||||
)
|
||||
(set! s (audio-sniff-format path))
|
||||
(hash-set! info 'sniffed s))
|
||||
(eq? s 'flac))))
|
||||
|
||||
(define (rep-id3 path)
|
||||
(set! report-flacs-with-id3
|
||||
@@ -117,7 +126,7 @@
|
||||
(hash-set! info 'orig-ext ext)
|
||||
(unless (eq? ext '||)
|
||||
(unless (memq ext known-exts)
|
||||
(hash-set! info 'ext 'unkown)
|
||||
(hash-set! info 'ext 'unknown)
|
||||
(unless (memq ext unknown-exts)
|
||||
(set! unknown-exts (sort (cons ext unknown-exts)
|
||||
kinds<))
|
||||
@@ -266,10 +275,8 @@
|
||||
(let ((path-part (get-path-part info)))
|
||||
(unless (eq? path-part #f)
|
||||
(let ((rm-path (build-path opus-path
|
||||
(if (flac? path info)
|
||||
(path-replace-extension
|
||||
(build-path opus-path path-part)
|
||||
#".opus")
|
||||
(if (presumed-flac? path info)
|
||||
(path-replace-extension path-part #".opus")
|
||||
path-part))))
|
||||
(delete-directory/files rm-path #:must-exist? #f)
|
||||
(let ((normalized-sub-path (hash-ref info 'path)))
|
||||
|
||||
Reference in New Issue
Block a user