about summary refs log tree commit homepage
path: root/lib/PublicInbox/SearchIdxShard.pm
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-06-10 07:05:02 +0000
committerEric Wong <e@yhbt.net>2020-06-13 07:55:45 +0000
commitcd389aac52936c82f3416b3ceefe21e1250b8a3e (patch)
treee68b068c3ec0d7aba3df80304fcb6cb398c1d589 /lib/PublicInbox/SearchIdxShard.pm
parentf77b21173e730a3daa8f5eed6d73835a682b3f04 (diff)
downloadpublic-inbox-cd389aac52936c82f3416b3ceefe21e1250b8a3e.tar.gz
NNTP and IMAP both require CRLF conversions on the wire.
They're also the only components which care about
$smsg->{bytes}, so store the CRLF-adjusted value in over.sqlite3
and Xapian DBs..

This will allow us to optimize RFC822.SIZE fetch item in IMAP
without triggering size mismatch errors in some clients' default
configurations (e.g. Mail::IMAPClient), but not most others.

It could also fix hypothetical problems with NNTP clients that
report discrepancies between overview and article data.
Diffstat (limited to 'lib/PublicInbox/SearchIdxShard.pm')
-rw-r--r--lib/PublicInbox/SearchIdxShard.pm11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/PublicInbox/SearchIdxShard.pm b/lib/PublicInbox/SearchIdxShard.pm
index c1f52d8b..f7ba293f 100644
--- a/lib/PublicInbox/SearchIdxShard.pm
+++ b/lib/PublicInbox/SearchIdxShard.pm
@@ -71,11 +71,11 @@ sub shard_worker_loop ($$$$$) {
                 } else {
                         chomp $line;
                         # n.b. $mid may contain spaces(!)
-                        my ($bytes, $num, $blob, $ds, $ts, $mid) =
-                                                        split(/ /, $line, 6);
+                        my ($to_read, $bytes, $num, $blob, $ds, $ts, $mid) =
+                                                        split(/ /, $line, 7);
                         $self->begin_txn_lazy;
-                        my $n = read($r, my $msg, $bytes) or die "read: $!\n";
-                        $n == $bytes or die "short read: $n != $bytes\n";
+                        my $n = read($r, my $msg, $to_read) or die "read: $!\n";
+                        $n == $to_read or die "short read: $n != $to_read\n";
                         my $mime = PublicInbox::Eml->new(\$msg);
                         my $smsg = bless {
                                 bytes => $bytes,
@@ -96,7 +96,8 @@ sub index_raw {
         my ($self, $msgref, $mime, $smsg) = @_;
         if (my $w = $self->{w}) {
                 # mid must be last, it can contain spaces (but not LF)
-                print $w join(' ', @$smsg{qw(bytes num blob ds ts mid)}),
+                print $w join(' ', @$smsg{qw(raw_bytes bytes
+                                                num blob ds ts mid)}),
                         "\n", $$msgref or die "failed to write shard $!\n";
         } else {
                 $$msgref = undef;