diff options
-rw-r--r-- | scripts/mumi.in | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/scripts/mumi.in b/scripts/mumi.in index e0a4d1a..ac2eb9b 100644 --- a/scripts/mumi.in +++ b/scripts/mumi.in @@ -55,10 +55,34 @@ (format (current-error-port) "Failed to index `~a'~%" (%config 'mail-dir))))))) +(define (fetch-messages!) + (let ((bug-nums + (sort (append-map (lambda (package) + (soap-invoke* (%config 'debbugs) + get-bugs + `((package . ,package)))) + (%config 'packages)) <))) + (for-each (lambda (bug-num i) + (let ((msg-nums + (match (soap-invoke* (%config 'debbugs) + get-bug-message-numbers + bug-num) + ((nums . ids) nums)))) + (format (current-error-port) + "[~a/~a] Refreshing ~a messages of bug ~a...~%" + i (length bug-nums) + (length msg-nums) bug-num) + (parameterize ((current-error-port (%make-void-port OPEN_WRITE))) + (par-for-each (cut download-message bug-num <>) + msg-nums)))) + bug-nums + (iota (length bug-nums) 1)))) + (define update-state! (lambda _ (catch #t (lambda () + (fetch-messages!) (mu-index) (update-bug-database!) (sleep %update-interval) @@ -105,27 +129,7 @@ ((assoc-ref opts 'worker) (update-state!)) ((assoc-ref opts 'fetch) - (let ((bug-nums - (sort (append-map (lambda (package) - (soap-invoke (%config 'debbugs) - get-bugs - `((package . ,package)))) - (%config 'packages)) <))) - (for-each (lambda (bug-num i) - (let ((msg-nums - (match (soap-invoke (%config 'debbugs) - get-bug-message-numbers - bug-num) - ((nums . ids) nums)))) - (format (current-error-port) - "[~a/~a] Downloading ~a messages of bug ~a...~%" - i (length bug-nums) - (length msg-nums) bug-num) - (parameterize ((current-error-port (%make-void-port OPEN_WRITE))) - (par-for-each (cut download-message bug-num <>) - msg-nums)))) - bug-nums - (iota (length bug-nums) 1)))) + (fetch-messages!)) (else (let ((repl-port (assoc-ref opts 'listen-repl))) (when repl-port |