From d155841744a0d8772988d55f380640c708b8e64b Mon Sep 17 00:00:00 2001 From: Hans Dijkema Date: Sun, 28 Jun 2026 14:02:42 +0200 Subject: [PATCH] small bug fixes --- audio-manager.rkt | 51 +++++++++++++++++++++++++++-------------------- info.rkt | 2 +- private/mail.rkt | 2 +- 3 files changed, 31 insertions(+), 24 deletions(-) diff --git a/audio-manager.rkt b/audio-manager.rkt index 7638e10..6d679aa 100644 --- a/audio-manager.rkt +++ b/audio-manager.rkt @@ -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))) diff --git a/info.rkt b/info.rkt index 7a0408c..f932b90 100644 --- a/info.rkt +++ b/info.rkt @@ -9,5 +9,5 @@ (define scribblings '(("scribblings/audio-library-manager.scrbl" ()))) (define build-deps '("rackunit-lib" "scribble-lib" "racket-doc")) (define pkg-desc "Audio library maintenance tools for FLAC and Opus trees") -(define version "0.2.2") +(define version "0.2.4") (define pkg-authors '(hans-dijkema)) diff --git a/private/mail.rkt b/private/mail.rkt index 8cc158a..9c4e186 100644 --- a/private/mail.rkt +++ b/private/mail.rkt @@ -26,7 +26,7 @@ (define (mail-report ini subject report) - (let-values (((from to server port user auth) (get-config ini))) + (let-values (((from to server port user passwd) (get-config ini))) (let* ((hdr (standard-message-header from (list to) '() '() subject))) (smtp-send-message server from (list to) hdr (if (list? report) report (list report))