summaryrefslogtreecommitdiff
path: root/scripts/mumi.in
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2020-03-31 16:16:54 +0200
committerRicardo Wurmus <rekado@elephly.net>2020-03-31 16:16:54 +0200
commit5fdbc3e717b8ed4bfef83294ed26361eb21c20c1 (patch)
tree91b1976a7b41f94215cb890afd373b6169cc1825 /scripts/mumi.in
parent5cb42e9fce80547c7abb77864626fec6d40ed4dd (diff)
scripts: Fetch messages regularly.
Diffstat (limited to 'scripts/mumi.in')
-rw-r--r--scripts/mumi.in46
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