]> Sergey Matveev's repositories - public-inbox.git/commitdiff
searchmsg: allow lines (and bytes) to be zero
authorEric Wong <e@yhbt.net>
Sat, 7 Mar 2020 10:57:02 +0000 (10:57 +0000)
committerEric Wong <e@yhbt.net>
Sat, 7 Mar 2020 19:10:31 +0000 (19:10 +0000)
We will occasionally see legit messages with zero lines,
be sure we index that count for NNTP clients.

I'm not sure about bytes being zero (aside from purged
messages), but we should've dealt with that earlier up
the stack.

lib/PublicInbox/SearchMsg.pm
t/v2mirror.t

index 42384936b923364bb17fc515bd6b39c0d83bc35e..84fe48025e564be6b81325f1fa43a6d206d1f124 100644 (file)
@@ -42,8 +42,8 @@ sub to_doc_data {
                $self->cc,
                $oid,
                $mid0,
-               $self->{bytes} || '',
-               $self->{lines} || ''
+               $self->{bytes} // '',
+               $self->{lines} // ''
        );
 }
 
index dc930d90518e342cd123dffef5e9ebf982e2f2ed..2e23e763de09a31cf2b59b09de9b48780f327c63 100644 (file)
@@ -55,6 +55,11 @@ for my $i (1..9) {
 my $epoch_max = $v2w->{epoch_max};
 ok($epoch_max > 0, "multiple epochs");
 $v2w->done;
+{
+       my $smsg = $ibx->over->get_art(1);
+       like($smsg->{lines}, qr/\A[0-9]+\z/, 'lines is a digit');
+       like($smsg->{bytes}, qr/\A[0-9]+\z/, 'bytes is a digit');
+}
 $ibx->cleanup;
 
 my $sock = tcp_server();