lib/PublicInbox/LeiSearch.pm | 8 ++++++-- lib/PublicInbox/LeiTag.pm | 10 ++++++++-- lib/PublicInbox/LeiToMail.pm | 4 +++- t/lei-index.t | 12 +++++++++++- diff --git a/lib/PublicInbox/LeiSearch.pm b/lib/PublicInbox/LeiSearch.pm index c2b1214679f012478dcb3bd34753cf8cefb6b4b7..fb19229fa868bc11f2d3228b74f17c19b2bb19d8 100644 --- a/lib/PublicInbox/LeiSearch.pm +++ b/lib/PublicInbox/LeiSearch.pm @@ -63,7 +63,9 @@ ($chash, $mids); } sub _cmp_1st { # git->cat_async callback - my ($bref, $oid, $type, $size, $cmp) = @_; # cmp: [chash, xoids, smsg] + my ($bref, $oid, $type, $size, $cmp) = @_; + # cmp: [chash, xoids, smsg, lms] + $bref //= $cmp->[3] ? $cmp->[3]->local_blob($oid, 1) : undef; if ($bref && content_hash(PublicInbox::Eml->new($bref)) eq $cmp->[0]) { $cmp->[1]->{$oid} = $cmp->[2]->{num}; } @@ -78,6 +80,8 @@ my ($chash, $mids) = content_key($eml); my @overs = ($self->over // $self->overs_all); my $git = $self->git; my $xoids = {}; + # no lms when used via {ale}: + my $lms = $self->{-lms_ro} //= lms($self) if defined($self->{topdir}); for my $mid (@$mids) { for my $o (@overs) { my ($id, $prev); @@ -85,7 +89,7 @@ while (my $cur = $o->next_by_mid($mid, \$id, \$prev)) { next if $cur->{bytes} == 0 || $xoids->{$cur->{blob}}; $git->cat_async($cur->{blob}, \&_cmp_1st, - [ $chash, $xoids, $cur ]); + [$chash, $xoids, $cur, $lms]); if ($min && scalar(keys %$xoids) >= $min) { $git->cat_async_wait; return $xoids; diff --git a/lib/PublicInbox/LeiTag.pm b/lib/PublicInbox/LeiTag.pm index c650e88633c999c430ab4f86a7a220d78878544d..b6abd53367f7cfe5c2c24d96b7f60d487d2399cb 100644 --- a/lib/PublicInbox/LeiTag.pm +++ b/lib/PublicInbox/LeiTag.pm @@ -9,7 +9,8 @@ use parent qw(PublicInbox::IPC PublicInbox::LeiInput); sub input_eml_cb { # used by PublicInbox::LeiInput::input_fh my ($self, $eml) = @_; - if (my $xoids = $self->{lei}->{ale}->xoids_for($eml)) { + if (my $xoids = $self->{lse}->xoids_for($eml) // # tries LeiMailSync + $self->{lei}->{ale}->xoids_for($eml)) { $self->{lei}->{sto}->ipc_do('update_xvmd', $xoids, $eml, $self->{vmd_mod}); } else { @@ -17,7 +18,11 @@ ++$self->{missing}; } } -sub input_mbox_cb { input_eml_cb($_[1], $_[0]) } +sub input_mbox_cb { + my ($eml, $self) = @_; + $eml->header_set($_) for (qw(X-Status Status)); + input_eml_cb($self, $eml); +} sub input_maildir_cb { # maildir_each_eml cb my ($f, $kw, $eml, $self) = @_; @@ -60,6 +65,7 @@ sub ipc_atfork_child { my ($self) = @_; PublicInbox::LeiInput::input_only_atfork_child($self); + $self->{lse} = $self->{lei}->{sto}->search; # this goes out-of-scope at worker process exit: PublicInbox::OnDestroy->new($$, \¬e_missing, $self); } diff --git a/lib/PublicInbox/LeiToMail.pm b/lib/PublicInbox/LeiToMail.pm index da3a95d20d2e1869124f77d1e4b0f14b17d28ec6..0cbdff8b8883bf8dddd134ee1eefa28f37406ef5 100644 --- a/lib/PublicInbox/LeiToMail.pm +++ b/lib/PublicInbox/LeiToMail.pm @@ -650,7 +650,9 @@ sub ipc_atfork_child { my ($self) = @_; my $lei = $self->{lei}; $lei->_lei_atfork_child; - $self->{-lms_ro} = $lei->{lse}->lms if $lei->{lse}; + if (my $lse = $lei->{lse}) { + $self->{-lms_ro} = $lse->{-lms_ro} //= $lse->lms; + } $lei->{auth}->do_auth_atfork($self) if $lei->{auth}; $SIG{__WARN__} = PublicInbox::Eml::warn_ignore_cb(); $self->SUPER::ipc_atfork_child; diff --git a/t/lei-index.t b/t/lei-index.t index b7dafb711f7eced8f31a0e118e3897490d666fcf..9a45d8856da497673449cf719a6f09f6f16a0dfb 100644 --- a/t/lei-index.t +++ b/t/lei-index.t @@ -40,7 +40,7 @@ lei_ok(qw(q mid:qp@example.com)); my $res_a = json_utf8->decode($lei_out); my $blob = $res_a->[0]->{'blob'}; like($blob, qr/\A[0-9a-f]{40,}\z/, 'got blob from qp@example'); - lei_ok('blob', $blob); + lei_ok(qw(-C / blob), $blob); is($lei_out, $expect, 'got expected blob via Maildir'); lei_ok(qw(q mid:qp@example.com -f text)); like($lei_out, qr/^hi = bye/sm, 'lei2mail fallback'); @@ -57,6 +57,16 @@ 'imported blob'); lei_ok(qw(q m:qp@example.com --dedupe=none)); my $res_b = json_utf8->decode($lei_out); is_deeply($res_b, $res_a, 'no extra DB entries'); + + # ensure tag works on index-only messages: + lei_ok(qw(tag +kw:seen t/utf8.eml)); + lei_ok(qw(q mid:testmessage@example.com)); + is_deeply(json_utf8->decode($lei_out)->[0]->{kw}, + ['seen'], 'seen kw can be set on index-only message'); + + lei_ok(qw(q z:0.. -o), "$tmpdir/all-results") for (1..2); + is_deeply([xqx($all_obj)], \@objs, + 'no new objects after 2x q to trigger implicit import'); lei_ok('index', "nntp://$nntp_host_port/t.v2"); lei_ok('index', "imap://$imap_host_port/t.v2.0");