Changed config.rkt to simple-ini.
This commit is contained in:
+25
-24
@@ -5,7 +5,7 @@
|
||||
racket/list
|
||||
racket/path
|
||||
"private/audio.rkt"
|
||||
"private/config.rkt"
|
||||
"private/manager-ini.rkt"
|
||||
"private/convert-place.rkt"
|
||||
"private/cover-art.rkt"
|
||||
"private/fingerprint.rkt"
|
||||
@@ -35,13 +35,11 @@
|
||||
(equal? (alist-ref/default old 'signature #f) signature)
|
||||
(not (equal? (alist-ref/default old 'status #f) 'error))))
|
||||
|
||||
(define (file-signature path config fingerprint-proc)
|
||||
(define mode (manager-config-change-detection config))
|
||||
(define (file-signature path ini fingerprint-proc)
|
||||
(define mode (string-downcase (ini-ref/string ini 'manager 'change-detection "flac-taglib")))
|
||||
(define hash-algorithm (string-downcase (ini-ref/string ini 'manager 'hash-algorithm "sha256")))
|
||||
(cond [(member mode '("hash" "sha256" "full-hash" "full-sha256"))
|
||||
(string-append "file:"
|
||||
(manager-config-hash-algorithm config)
|
||||
":"
|
||||
(file-digest path (manager-config-hash-algorithm config)))]
|
||||
(string-append "file:" hash-algorithm ":" (file-digest path hash-algorithm))]
|
||||
[(member mode '("mtime-size" "quick"))
|
||||
(format "mtime-size:~a:~a" (file-size path) (file-or-directory-modify-seconds path))]
|
||||
[(member mode '("flac" "flac-streaminfo"))
|
||||
@@ -66,7 +64,7 @@
|
||||
(when cover (info-alm "embedded sidecar cover in ~a from ~a" relpath cover))
|
||||
cover))
|
||||
|
||||
(define (process-one-file ks config path relpath inspect-flac-proc fingerprint-proc convert-proc summary errors)
|
||||
(define (process-one-file ks ini path relpath inspect-flac-proc fingerprint-proc convert-proc summary errors)
|
||||
;; Only invokes TagLib when a sidecar cover/folder image exists in the same directory.
|
||||
;; This keeps the cheap mtime/size fast path cheap for most directories, but still
|
||||
;; lets the manager repair missing embedded artwork before fingerprinting.
|
||||
@@ -90,25 +88,25 @@
|
||||
(cons 'message (exn-message e)))
|
||||
errors)))])
|
||||
(define sample-rate (inspect-flac-proc path))
|
||||
(define signature (file-signature path config fingerprint-proc))
|
||||
(define signature (file-signature path ini fingerprint-proc))
|
||||
(cond [(same-signature-state? old signature)
|
||||
(info-alm "unchanged fingerprint: ~a" relpath)
|
||||
(state-set-file! ks relpath (state-info path signature 'unchanged sample-rate '()))
|
||||
(values (summary-inc summary2 'unchanged) errors)]
|
||||
[(> sample-rate (manager-config-max-sample-rate config))
|
||||
(if (manager-config-dry-run? config)
|
||||
[(> sample-rate (ini-ref/int ini 'manager 'max-sample-rate 48000))
|
||||
(if (ini-ref/bool ini 'manager 'dry-run #f)
|
||||
(begin
|
||||
(warn-alm "dry-run: would convert ~a from ~a Hz to ~a Hz" relpath sample-rate (manager-config-max-sample-rate config))
|
||||
(warn-alm "dry-run: would convert ~a from ~a Hz to ~a Hz" relpath sample-rate (ini-ref/int ini 'manager 'max-sample-rate 48000))
|
||||
(state-set-file! ks relpath
|
||||
(state-info path signature 'dry-run sample-rate '()))
|
||||
(values (summary-inc (summary-inc summary2 'skipped) 'dry-run) errors))
|
||||
(begin
|
||||
(info-alm "converting ~a from ~a Hz to ~a Hz" relpath sample-rate (manager-config-max-sample-rate config))
|
||||
(info-alm "converting ~a from ~a Hz to ~a Hz" relpath sample-rate (ini-ref/int ini 'manager 'max-sample-rate 48000))
|
||||
(let* ((result (convert-proc path
|
||||
(manager-config-max-sample-rate config)
|
||||
(manager-config-compression-level config)))
|
||||
(ini-ref/int ini 'manager 'max-sample-rate 48000)
|
||||
(ini-ref/int ini 'manager 'compression-level 5)))
|
||||
(new-sample-rate (inspect-flac-proc path))
|
||||
(new-signature (file-signature path config fingerprint-proc)))
|
||||
(new-signature (file-signature path ini fingerprint-proc)))
|
||||
(state-set-file! ks relpath
|
||||
(state-info path new-signature 'converted new-sample-rate
|
||||
(list (cons 'old-sample-rate sample-rate)
|
||||
@@ -136,22 +134,25 @@
|
||||
(define base-dir (filesystem-path base-directory))
|
||||
(unless (directory-exists? base-dir)
|
||||
(raise-argument-error 'manage-flac-tree "existing directory" base-directory))
|
||||
(define config (load-manager-config base-dir))
|
||||
(setup-logging! (manager-config-log-file config) (manager-config-display-log? config))
|
||||
(define ini-file (manager-ini-file base-dir))
|
||||
(define state-file (manager-state-file base-dir))
|
||||
(define ini (load-manager-ini base-dir))
|
||||
(setup-logging! (ini-ref/path ini base-dir 'manager 'log-file ".flac-48khz-manager.log")
|
||||
(ini-ref/bool ini 'manager 'display-log #t))
|
||||
(info-alm "base directory: ~a" base-dir)
|
||||
(info-alm "state file: ~a" (manager-config-state-file config))
|
||||
(info-alm "ini file: ~a" (manager-config-ini-file config))
|
||||
(info-alm "change detection: ~a" (manager-config-change-detection config))
|
||||
(define ks (open-manager-state (manager-config-state-file config)))
|
||||
(info-alm "state file: ~a" state-file)
|
||||
(info-alm "ini file: ~a" ini-file)
|
||||
(info-alm "change detection: ~a" (ini-ref/string ini 'manager 'change-detection "flac-taglib"))
|
||||
(define ks (open-manager-state state-file))
|
||||
(define files (find-flac-files base-dir))
|
||||
(define relpaths (map (lambda (p) (relpath-string base-dir p)) files))
|
||||
(define summary0 (drop-removed! ks relpaths (make-empty-summary)))
|
||||
(define-values (summary errors)
|
||||
(for/fold ([summary summary0] [errors '()]) ([p (in-list files)] [rel (in-list relpaths)])
|
||||
(process-one-file ks config p rel inspect-flac-proc fingerprint-proc convert-proc summary errors)))
|
||||
(process-one-file ks ini p rel inspect-flac-proc fingerprint-proc convert-proc summary errors)))
|
||||
(define errors* (reverse errors))
|
||||
(with-handlers ([exn:fail? (lambda (e) (err-alm "mail report failed: ~a" (exn-message e)) (void))])
|
||||
(maybe-send-report-mail config summary errors*))
|
||||
(maybe-send-report-mail ini summary errors*))
|
||||
(for ([line (in-list (summary->lines summary))]) (info-alm "summary: ~a" line))
|
||||
summary)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user