From 601658e48f0e28ca178ef5c4d7eed0e50ef42167 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 10 Jun 2020 07:04:52 +0000 Subject: search: index byte size of a message for IMAP search Searching for messages smaller than a certain size is allowed by offlineimap(1), mbsync(1), and possibly other tools. Maybe public-inbox-watch will support it, too. I don't see a reason to expose searching by size via WWW search right now (but maybe in the future, I could be convinced to). Note: we only store the byte-size of the message in git, this is typically LF-only and we won't have the correct size after CRLF conversion for NNTP or IMAP. --- lib/PublicInbox/SearchIdx.pm | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/PublicInbox/SearchIdx.pm') diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm index f4fa50ff..f7462aa7 100644 --- a/lib/PublicInbox/SearchIdx.pm +++ b/lib/PublicInbox/SearchIdx.pm @@ -341,6 +341,7 @@ sub add_xapian ($$$$) { add_val($doc, PublicInbox::Search::YYYYMMDD(), $yyyymmdd); my $dt = strftime('%Y%m%d%H%M%S', @ds); add_val($doc, PublicInbox::Search::DT(), $dt); + add_val($doc, PublicInbox::Search::BYTES(), $smsg->{bytes}); my $tg = term_generator($self); $tg->set_document($doc); @@ -388,6 +389,7 @@ sub add_message { # v1 and tests only: $smsg->populate($hdr, $self); + $smsg->{bytes} //= length($mime->as_string); eval { # order matters, overview stores every possible piece of -- cgit v1.2.3-24-ge0c7