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. --- t/search.t | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 't') diff --git a/t/search.t b/t/search.t index 6cf2bc2d..cf325416 100644 --- a/t/search.t +++ b/t/search.t @@ -318,6 +318,12 @@ $ibx->with_umask(sub { foreach my $m ($mset->items) { my $smsg = $ro->{over_ro}->get_art($m->get_docid); like($smsg->{to}, qr/\blist\@example\.com\b/, 'to appears'); + my $doc = $m->get_document; + my $col = PublicInbox::Search::BYTES(); + my $bytes = PublicInbox::Smsg::get_val($doc, $col); + like($bytes, qr/\A[0-9]+\z/, '$bytes stored as digit'); + ok($bytes > 0, '$bytes is > 0'); + is($bytes, $smsg->{bytes}, 'bytes Xapian value matches Over'); } $mset = $ro->query('tc:list@example.com', {mset => 1}); -- cgit v1.2.3-24-ge0c7