From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 3AB1E1FFAD for ; Tue, 27 Oct 2020 07:54:55 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 11/52] searchidxshard: allow msgref to be undef Date: Tue, 27 Oct 2020 07:54:12 +0000 Message-Id: <20201027075453.19163-12-e@80x24.org> In-Reply-To: <20201027075453.19163-1-e@80x24.org> References: <20201027075453.19163-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: We don't need to keep it in code paths which are guaranteed to only see PublicInbox::Eml (and not Email::MIME or PublicInbox::MIME which did not round-trip properly). However, we must set {raw_bytes} since PublicInbox::Eml may add an extra "\n" for rare messages with no bodies. --- lib/PublicInbox/SearchIdxShard.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/PublicInbox/SearchIdxShard.pm b/lib/PublicInbox/SearchIdxShard.pm index 8e24aa1b..8ff9ab8b 100644 --- a/lib/PublicInbox/SearchIdxShard.pm +++ b/lib/PublicInbox/SearchIdxShard.pm @@ -107,13 +107,15 @@ sub shard_worker_loop ($$$$$) { sub index_raw { my ($self, $msgref, $eml, $smsg) = @_; if (my $w = $self->{w}) { + $msgref //= \($eml->as_string); + $smsg->{raw_bytes} //= length($$msgref); # mid must be last, it can contain spaces (but not LF) print $w join(' ', @$smsg{qw(raw_bytes bytes num blob ds ts tid mid)}), "\n", $$msgref or die "failed to write shard $!\n"; } else { if ($eml) { - undef $$msgref; + undef($$msgref) if $msgref; } else { # --xapian-only + --sequential-shard: $eml = PublicInbox::Eml->new($msgref); }