From 715d7501fca8ffd7c18b0ecec8f1d8550690d15d Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Sun, 23 May 2021 17:46:20 -0400 Subject: Rework url-retrieve-synchronously wrapper piem-download-and-decompress calls url-retrieve-synchronously, checks for a 200 status, and then manually removes the header. This works okay, but it'd be good for the error handling to match what's done by url-insert-file-contents. Introduce a new macro that largely copies what is done by url-insert-file-contents. The main difference is that url-insert is used instead of url-insert-buffer-contents so that the contents can be inserted literally. This approach is based on Emacs's 5f9671e57e (lisp/emacs-lisp/package.el: Fix decoding of downloaded files, 2019-05-18). Message-Id: <20210523214623.31331-3-kyle@kyleam.com> --- piem-b4.el | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'piem-b4.el') diff --git a/piem-b4.el b/piem-b4.el index 48c8bf4..92ddea8 100644 --- a/piem-b4.el +++ b/piem-b4.el @@ -73,15 +73,14 @@ This is intended to be used for debugging purposes.") ;; back to b4's configuration. (unless local-mbox-p (when-let ((url (and (equal mid (piem-mid)) - (piem-inbox-get :url))) - (buffer (condition-case nil - (piem-download-and-decompress - (concat url (piem-escape-mid mid) "/t.mbox.gz")) - (error nil)))) - (with-current-buffer buffer - (write-region nil nil mbox-thread)) - (kill-buffer buffer) - (setq local-mbox-p t))) + (piem-check-gunzip) + (piem-inbox-get :url)))) + (ignore-errors + (piem-with-url-contents + (concat url (piem-escape-mid mid) "/t.mbox.gz") + (piem-gunzip-buffer) + (write-region nil nil mbox-thread)) + (setq local-mbox-p t)))) ;; Move to the coderepo so that we pick up any b4 configuration ;; from there. (condition-case err -- cgit v1.2.3