From 2d513a2e24a6acd223ca3093c3fb2272865366dc Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Thu, 19 Dec 2024 12:29:16 +0000 Subject: Fix check for not stored files --- nar-herder/storage.scm | 55 +++++++++++++++++++++++++++----------------------- 1 file 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 -- cgit v1.2.3