From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms12 with LMTPS id wP0mEYXeOV+ODwAAsNZ9tg (envelope-from ) for ; Mon, 17 Aug 2020 01:33:57 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id QGP6DIXeOV95WQAAB5/wlQ (envelope-from ) for ; Mon, 17 Aug 2020 01:33:57 +0000 Received: from pb-smtp2.pobox.com (pb-smtp2.pobox.com [64.147.108.71]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id B35879404D3 for ; Mon, 17 Aug 2020 01:33:56 +0000 (UTC) Received: from pb-smtp2.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 991C37E76C; Sun, 16 Aug 2020 21:33:55 -0400 (EDT) (envelope-from kyle@kyleam.com) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=sasl; bh=szfq2cRgXT37GgA9btFUbnh12 tk=; b=wKXReAPnxGn7pDxQ6dfTjDVlLirqYoNXmzfZBYlQY0crl9tA/wvZCgVFX UaOfPS2B8Ck50f1OWXIkYBmOhpwYG3C39Q24FkHElOnZGFKUQXmAUYJPgbJbnvY9 o4ZPnRzGp2yIdnd/useEa6LMKMgkDnWK7wqNbhtzHm2Z6MatCc= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 9045F7E76A; Sun, 16 Aug 2020 21:33:55 -0400 (EDT) (envelope-from kyle@kyleam.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=kyleam.com; h=from:to:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=mesmtp; bh=aRGPifFcwYjNOgrrlOlQ+9buuVfbQKkcuX65ZByyvS0=; b=NFBdzxpMKxdFtFD4KcUE+IJHE55t3N84egEh1vv/mZtH8tx5ejMSRGFN1/GSKQC/rb9N7u6jrh950YPg+XWN2zPb0tKF44sVQ0tUEntD0mcc4sJt2fEZe9mZd/ltIdML4uCSPoz+vOlT8Lkw8i43b+DUK2fK+1NnNuxhIm7yGeM= Received: from localhost (unknown [45.33.91.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id 13EFE7E768; Sun, 16 Aug 2020 21:33:55 -0400 (EDT) (envelope-from kyle@kyleam.com) From: Kyle Meyer To: piem@inbox.kyleam.com Subject: [PATCH 3/5] Extract logic from inject-thread-callback Date: Sun, 16 Aug 2020 21:33:41 -0400 Message-Id: <20200817013343.15615-4-kyle@kyleam.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817013343.15615-1-kyle@kyleam.com> References: <20200817013343.15615-1-kyle@kyleam.com> MIME-Version: 1.0 X-Pobox-Relay-ID: B6A7EA2A-E029-11EA-8E2D-2F5D23BA3BAF-24757444!pb-smtp2.pobox.com Content-Transfer-Encoding: quoted-printable X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=pobox.com header.s=sasl header.b=wKXReAPn; dkim=fail (body hash did not verify) header.d=kyleam.com header.s=mesmtp header.b=NFBdzxpM; dmarc=none; spf=pass (aspmx1.migadu.com: domain of kyle@kyleam.com designates 64.147.108.71 as permitted sender) smtp.mailfrom=kyle@kyleam.com X-Spam-Score: 2.50 X-TUID: F/hNJ1nrWyVi 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) =20 +(defun piem--url-remove-header () + (goto-char (1+ url-http-end-of-headers)) + (delete-region (point-min) (point))) + +(defun piem--url-decompress () + (unless (=3D 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 mess= age-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 (=3D 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)) --=20 2.28.0