diff options
author | Christopher Baines <mail@cbaines.net> | 2024-12-19 12:29:16 +0000 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2024-12-19 12:34:25 +0000 |
commit | 2d513a2e24a6acd223ca3093c3fb2272865366dc (patch) | |
tree | 59d90d22025819ef9b14da67d883fecbe386152c | |
parent | 6d0a10f35695a28c78651930188f8e5f1ad9ba73 (diff) | |
download | nar-herder-2d513a2e24a6acd223ca3093c3fb2272865366dc.tar nar-herder-2d513a2e24a6acd223ca3093c3fb2272865366dc.tar.gz |
Fix check for not stored files
-rw-r--r-- | nar-herder/storage.scm | 55 |
1 files changed, 30 insertions, 25 deletions
diff --git a/nar-herder/storage.scm b/nar-herder/storage.scm index 87e2ff1..55e374e 100644 --- a/nar-herder/storage.scm +++ b/nar-herder/storage.scm @@ -288,31 +288,36 @@ (define files-count (database-count-narinfo-files database)) - (call-with-progress-reporter - (progress-reporter/bar files-count - (simple-format #f "checking ~A files" files-count) - (current-error-port)) - (lambda (report) - (fold-nar-files - database - storage-root - (lambda (file _) - (let* ((full-filename - (string-append storage-root - (uri-decode (assq-ref file 'url)))) - (file-size - (stat:size (stat full-filename))) - (database-size - (assq-ref file 'size))) - (report) - (unless (= file-size database-size) - (newline) - (log-msg 'WARN "file " full-filename - " has inconsistent size (database: " - database-size ", file: " file-size ")")) - #f)) - #f - #:stored? 'both)))) + (let ((not-stored-count + (call-with-progress-reporter + (progress-reporter/bar files-count + (simple-format #f "checking ~A files" files-count) + (current-error-port)) + (lambda (report) + (fold-nar-files + database + storage-root + (lambda (file not-stored-count) + (let* ((full-filename + (string-append storage-root + (uri-decode (assq-ref file 'url))))) + (if (file-exists? full-filename) + (let ((file-size + (stat:size (stat full-filename))) + (database-size + (assq-ref file 'size))) + (report) + (unless (= file-size database-size) + (newline) + (log-msg 'WARN "file " full-filename + " has inconsistent size (database: " + database-size ", file: " file-size ")")) + not-stored-count) + (+ 1 not-stored-count)))) + 0 + #:stored? 'both))))) + + (log-msg 'INFO "finished checking, " not-stored-count " files not stored"))) (define (at-most max-length lst) "If LST is shorter than MAX-LENGTH, return it and the empty list; otherwise |