keep original file info in file-walker and make sure changed files are processed properly
This commit is contained in:
+14
-13
@@ -59,7 +59,7 @@
|
||||
(eq? state 'changed)
|
||||
(eq? state 'new)))))
|
||||
|
||||
(define (needs-copying? info)
|
||||
(define (needs-copying? path info)
|
||||
(let ((state (hash-ref info 'file-db #f)))
|
||||
(and (eq? (hash-ref info 'type #f) 'file)
|
||||
(not (eq? state 'deleted))
|
||||
@@ -99,12 +99,13 @@
|
||||
(eq? (hash-ref info 'ext) 'flac)))
|
||||
|
||||
(define (flac? path info)
|
||||
(when (presumed-flac? info)
|
||||
(if (presumed-flac? info)
|
||||
(let ((s (hash-ref info 'sniffed #f)))
|
||||
(when (eq? s #f)
|
||||
(set! s (audio-sniff-format path))
|
||||
(hash-set! info 'sniffed s))
|
||||
(eq? s 'flac))))
|
||||
(eq? s 'flac))
|
||||
#f))
|
||||
|
||||
(define (rep-id3 path)
|
||||
(set! report-flacs-with-id3
|
||||
@@ -136,7 +137,10 @@
|
||||
|
||||
(define (flac-with-id3 base-path path info)
|
||||
(if (or (needs-processing? path info)
|
||||
(eq? (hash-ref info 'sniffed #f) #f))
|
||||
(and
|
||||
(eq? (hash-ref info 'type #f) 'file)
|
||||
(eq? (hash-ref info 'sniffed #f) #f)
|
||||
(not (deleted? info))))
|
||||
(let ((ext (hash-ref info 'ext)))
|
||||
(when (memq ext known-audio-exts)
|
||||
(let ((sniffed (audio-sniff-format path)))
|
||||
@@ -152,12 +156,9 @@
|
||||
|
||||
(define (flac-khz-bits base-path path info)
|
||||
(when (and (needs-processing? path info) (flac? path info))
|
||||
(when (or (eq? (hash-ref info 'khz #f) #f)
|
||||
(eq? (hash-ref info 'bits #f) #f))
|
||||
(let-values (((khz bits) (determine-flac-khz-and-bits path)))
|
||||
(hash-set! info 'khz khz)
|
||||
(hash-set! info 'bits bits)
|
||||
)
|
||||
(let-values (((khz bits) (determine-flac-khz-and-bits path)))
|
||||
(hash-set! info 'khz khz)
|
||||
(hash-set! info 'bits bits)
|
||||
)
|
||||
)
|
||||
(values base-path path info)
|
||||
@@ -254,7 +255,7 @@
|
||||
|
||||
;; Kopieer bestanden rechtstreeks indien nodig en geen flac
|
||||
(define (copy-other base-path path info)
|
||||
(when (and (needs-copying? info)
|
||||
(when (and (needs-copying? path info)
|
||||
(not (flac? path info)))
|
||||
(with-handlers ([exn? (λ (e)
|
||||
(set! failed-copies (+ failed-copies 1))
|
||||
@@ -275,7 +276,7 @@
|
||||
(let ((path-part (get-path-part info)))
|
||||
(unless (eq? path-part #f)
|
||||
(let ((rm-path (build-path opus-path
|
||||
(if (presumed-flac? path info)
|
||||
(if (presumed-flac? info)
|
||||
(path-replace-extension path-part #".opus")
|
||||
path-part))))
|
||||
(delete-directory/files rm-path #:must-exist? #f)
|
||||
@@ -371,7 +372,7 @@
|
||||
(sl-set-log-level log-level)
|
||||
|
||||
(let ((fw (make-file-admin music-path file-db-hash)))
|
||||
;; Enrichement phase
|
||||
;; Enrichment phase
|
||||
(set! fw (fw-add-step fw adjust-ext))
|
||||
(set! fw (fw-add-step fw flac-with-id3))
|
||||
(set! fw (fw-add-step fw flac-khz-bits))
|
||||
|
||||
@@ -5,9 +5,10 @@
|
||||
"racket-audio"
|
||||
"simple-ini"
|
||||
"simple-log"
|
||||
"net-lib"
|
||||
))
|
||||
(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.4")
|
||||
(define version "0.2.6")
|
||||
(define pkg-authors '(hans-dijkema))
|
||||
|
||||
@@ -85,15 +85,19 @@
|
||||
((eq? in-db #f)
|
||||
(hash-set! info 'file-db 'new)
|
||||
(hash-set! db-hash normalized-sub-path info)
|
||||
(values base-path path info)
|
||||
)
|
||||
(else
|
||||
(if (file-info-equal? info in-db)
|
||||
(hash-set! info 'file-db 'unchanged)
|
||||
(hash-set! info 'file-db 'changed))
|
||||
(hash-set! db-hash normalized-sub-path info)
|
||||
(hash-set! in-db 'file-db 'unchanged)
|
||||
(begin
|
||||
(hash-set! in-db 'file-db 'changed)
|
||||
(hash-set! in-db 'size (hash-ref info 'size))
|
||||
(hash-set! in-db 'mtime (hash-ref info 'mtime))))
|
||||
(hash-set! db-hash normalized-sub-path in-db)
|
||||
(values base-path path in-db)
|
||||
)
|
||||
)
|
||||
(values base-path path info)
|
||||
))
|
||||
|
||||
(define (init-db-sweep)
|
||||
|
||||
Reference in New Issue
Block a user