about summary refs log tree commit homepage
path: root/lib/PublicInbox/IMAP.pm
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-06-10 07:05:03 +0000
committerEric Wong <e@yhbt.net>2020-06-13 07:55:45 +0000
commitdb95fdf669b11a0d3c3259e0ef7a1cbdb14ba1f3 (patch)
treed4372559c7831ebf6f51dc7a9f1ee15da0024126 /lib/PublicInbox/IMAP.pm
parentcd389aac52936c82f3416b3ceefe21e1250b8a3e (diff)
downloadpublic-inbox-db95fdf669b11a0d3c3259e0ef7a1cbdb14ba1f3.tar.gz
imap: rely on smsg->{bytes} for RFC822.SIZE
Since we started indexing the CRLF-adjusted size of messages,
we can take an order-of-magnitude speedup for certain MUAs
which fetch this attribute without needing much else.

Admins are encouraged to --reindex existing inboxes for IMAP
support, anyways.  It won't be fatal if it's not reindexed, but
some client bugs and warnings can be fixed and they'll be able
to support more of IMAP.
Diffstat (limited to 'lib/PublicInbox/IMAP.pm')
-rw-r--r--lib/PublicInbox/IMAP.pm11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/PublicInbox/IMAP.pm b/lib/PublicInbox/IMAP.pm
index 803ce31f..9cdcba69 100644
--- a/lib/PublicInbox/IMAP.pm
+++ b/lib/PublicInbox/IMAP.pm
@@ -53,7 +53,7 @@ my %FETCH_NEED = (
         'BODY[]' => [ NEED_BLOB, \&emit_rfc822 ],
         'RFC822.HEADER' => [ NEED_EML, \&emit_rfc822_header ],
         'RFC822.TEXT' => [ NEED_EML, \&emit_rfc822_text ],
-        'RFC822.SIZE' => [ NEED_BLOB, \&emit_rfc822_size ],
+        'RFC822.SIZE' => [ NEED_SMSG, \&emit_rfc822_size ],
         RFC822 => [ NEED_BLOB, \&emit_rfc822 ],
         BODY => [ NEED_EML, \&emit_body ],
         BODYSTRUCTURE => [ NEED_EML, \&emit_bodystructure ],
@@ -500,11 +500,12 @@ sub emit_rfc822 {
         $self->msg_more($$bref);
 }
 
-# Mail::IMAPClient::message_string cares about this by default
-# (->Ignoresizeerrors attribute)
+# Mail::IMAPClient::message_string cares about this by default,
+# (->Ignoresizeerrors attribute).  Admins are encouraged to
+# --reindex for IMAP support, anyways.
 sub emit_rfc822_size {
-        my ($self, $k, undef, $bref) = @_;
-        $self->msg_more(' RFC822.SIZE ' . length($$bref));
+        my ($self, $k, $smsg) = @_;
+        $self->msg_more(' RFC822.SIZE ' . $smsg->{bytes});
 }
 
 sub emit_internaldate {