about summary refs log tree commit homepage
path: root/lib/PublicInbox/SearchIdx.pm
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-06-10 07:04:52 +0000
committerEric Wong <e@yhbt.net>2020-06-13 07:55:45 +0000
commit601658e48f0e28ca178ef5c4d7eed0e50ef42167 (patch)
treee78b5ee412bfb4982cfb08316071f182cb5a71ea /lib/PublicInbox/SearchIdx.pm
parent77fe488ce5432a49ea8499605e0d8e155834575f (diff)
downloadpublic-inbox-601658e48f0e28ca178ef5c4d7eed0e50ef42167.tar.gz
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.
Diffstat (limited to 'lib/PublicInbox/SearchIdx.pm')
-rw-r--r--lib/PublicInbox/SearchIdx.pm2
1 files changed, 2 insertions, 0 deletions
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