From: Kyle Meyer <kyle@kyleam.com>
To: piem@inbox.kyleam.com
Subject: [PATCH 3/5] Extract logic from inject-thread-callback
Date: Sun, 16 Aug 2020 21:33:41 -0400 [thread overview]
Message-ID: <20200817013343.15615-4-kyle@kyleam.com> (raw)
In-Reply-To: <20200817013343.15615-1-kyle@kyleam.com>
An upcoming commit will use this same logic in another callback.
---
piem.el | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/piem.el b/piem.el
index 4b35938..94fa1ad 100644
--- a/piem.el
+++ b/piem.el
@@ -372,6 +372,16 @@ (defun piem-check-gunzip ()
(setq piem--has-gunzip (executable-find "gunzip")))
piem--has-gunzip)
+(defun piem--url-remove-header ()
+ (goto-char (1+ url-http-end-of-headers))
+ (delete-region (point-min) (point)))
+
+(defun piem--url-decompress ()
+ (unless (= 0 (call-process-region nil nil "gunzip" nil t))
+ (error "Decompressing t.mbox.gz failed"))
+ (delete-region (point) (point-max))
+ (goto-char (point-min)))
+
(defun piem--write-mbox-to-maildir ()
(let ((n-messages 0))
(while (and (not (eobp))
@@ -406,13 +416,9 @@ (defun piem--inject-thread-callback (status mid message-only)
(let ((error-status (plist-get status :error)))
(if error-status
(signal (car error-status) (cdr error-status))
- (goto-char (1+ url-http-end-of-headers))
- (delete-region (point-min) (point))
+ (piem--url-remove-header)
(unless message-only
- (unless (= 0 (call-process-region nil nil "gunzip" nil t))
- (error "Decompressing t.mbox.gz failed"))
- (delete-region (point) (point-max)))
- (goto-char (point-min))
+ (piem--url-decompress))
(let ((message-count (piem--write-mbox-to-maildir)))
(message "%d message(s) for %s moved to %s"
message-count mid piem-maildir-directory))
--
2.28.0
next prev parent reply other threads:[~2020-08-17 1:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-17 1:33 [PATCH 0/5] b4: Try to download thread from piem-inboxes URL Kyle Meyer
2020-08-17 1:33 ` [PATCH 1/5] Use url-http-end-of-headers move to payload Kyle Meyer
2020-08-17 1:33 ` [PATCH 2/5] Move "has gunzip?" check to helper Kyle Meyer
2020-08-17 1:33 ` Kyle Meyer [this message]
2020-08-17 1:33 ` [PATCH 4/5] b4: Use a clearer variable name Kyle Meyer
2020-08-17 1:33 ` [PATCH 5/5] b4: Try to download thread from piem-inboxes URL Kyle Meyer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://git.kyleam.com/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200817013343.15615-4-kyle@kyleam.com \
--to=kyle@kyleam.com \
--cc=piem@inbox.kyleam.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.kyleam.com/piem/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).