aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2019-09-26 18:08:12 +0100
committerChristopher Baines <mail@cbaines.net>2019-09-26 18:08:12 +0100
commit759b75257ec981f52747da657e83f623d6880660 (patch)
tree842b186efdcbcc3f2804ea829fe3ad2f9a3e44ac
parentbb94f6dd05a33135fa661b86d35d203c0c099dba (diff)
downloaddata-service-759b75257ec981f52747da657e83f623d6880660.tar
data-service-759b75257ec981f52747da657e83f623d6880660.tar.gz
Switch to processing emails as bytevectors
This is better, as different parts of the email might be encoded differently, and guile-email will take care of this if handed a bytevector.
-rw-r--r--scripts/guix-data-service-process-branch-updated-email.in41
1 files changed, 21 insertions, 20 deletions
diff --git a/scripts/guix-data-service-process-branch-updated-email.in b/scripts/guix-data-service-process-branch-updated-email.in
index 429684a..d8f6196 100644
--- a/scripts/guix-data-service-process-branch-updated-email.in
+++ b/scripts/guix-data-service-process-branch-updated-email.in
@@ -23,6 +23,8 @@
(use-modules (srfi srfi-1)
(srfi srfi-37)
(ice-9 textual-ports)
+ (ice-9 binary-ports)
+ (rnrs bytevectors)
(squee)
(email email)
(guix-data-service database)
@@ -31,23 +33,22 @@
(with-postgresql-connection
"process-branch-updated-email"
(lambda (conn)
- (let* ((email-string
- (get-string-all (current-input-port)))
- (email
- (catch
- #t
- (lambda ()
- (parse-email email-string))
- (lambda (key . args)
- (display "\nerror: while processing email\n"
- (current-error-port))
- (simple-format (current-error-port)
- "~A: ~A\n\n"
- key
- args)
- (display email-string (current-error-port))
- (display "\n\n" (current-error-port))
- #f))))
- (when email
- (enqueue-job-for-email conn email)))))
-
+ (let* ((email-bytevector
+ (get-bytevector-all (current-input-port))))
+ (catch
+ #t
+ (lambda ()
+ (with-throw-handler #t
+ (lambda ()
+ (enqueue-job-for-email
+ conn
+ (parse-email email-bytevector)))
+ (lambda (key . args)
+ (display "\nerror: while parsing email\n"
+ (current-error-port))
+ (simple-format (current-error-port)
+ "~A: ~A\n\n"
+ key
+ args)
+ (display-backtrace (make-stack #t) (current-error-port)))))
+ (lambda (key . args) #f)))))