summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mumi/config.scm.in10
-rw-r--r--mumi/messages.scm28
2 files changed, 38 insertions, 0 deletions
diff --git a/mumi/config.scm.in b/mumi/config.scm.in
index b122f39..4a0b69d 100644
--- a/mumi/config.scm.in
+++ b/mumi/config.scm.in
@@ -30,6 +30,16 @@
maybe-dir
;; TODO: use @assetsdir@ variable here
"@prefix@/share/mumi/assets")))
+ (mail-dir . ,(let ((maybe-dir
+ (string-append (getcwd) "/mails")))
+ (if (and (getenv "MUMI_UNINSTALLED")
+ (file-exists? maybe-dir))
+ maybe-dir
+ (let ((dir "@localstatedir@/mumi/mails"))
+ (if (string-prefix? "${prefix}" dir)
+ (string-replace dir "@prefix@"
+ 0 (string-length "${prefix}"))
+ dir)))))
(host . "localhost")
(port . 1234)
(submission-email-address . "guix-patches@gnu.org")
diff --git a/mumi/messages.scm b/mumi/messages.scm
index 6a70114..34ab02f 100644
--- a/mumi/messages.scm
+++ b/mumi/messages.scm
@@ -24,6 +24,7 @@
#:use-module (ice-9 regex)
#:use-module (ice-9 match)
#:use-module (ice-9 textual-ports)
+ #:use-module (ice-9 binary-ports)
#:use-module (debbugs cache)
#:use-module (debbugs soap)
#:use-module (debbugs operations)
@@ -35,6 +36,8 @@
recent-bugs
bugs-by-severity
+ download-message
+
multipart-message?
extract-attachment))
@@ -145,6 +148,31 @@ we have to do this in a very convoluted way."
(_ #f)))))))))
+(define (download-message bug-id msg-num)
+ "Download message number MSG-NUM of bug BUG-ID and store it in the
+mail directory if it's not already there. Return the name of the
+target file."
+ (let ((key (list 'download-message bug-id msg-num)))
+ (or (cached? key)
+ (cache! key
+ (let ((file-name (format #f "~a/cur/~a-~a"
+ (%config 'mail-dir)
+ bug-id msg-num)))
+ (if (file-exists? file-name) file-name
+ (begin
+ (format (current-error-port)
+ "downloading ~a~%" file-name)
+ (call-with-values
+ (lambda ()
+ (fetch-mbox (%config 'debbugs)
+ bug-id msg-num #:streaming? #t))
+ (lambda (response port)
+ (with-output-to-file file-name
+ (lambda ()
+ (put-bytevector (current-output-port)
+ (get-bytevector-all port))))))
+ file-name)))))))
+
(define-public (patch-messages id)
"Return list of messages relating to the bug ID."
;; TODO: sort by date necessary?