about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-05-21 10:28:27 +0000
committerEric Wong <e@80x24.org>2021-05-23 01:33:03 +0000
commitdc890423db7c63c07ab248309accb429df405576 (patch)
treed721fd1219a40184442793b03ce40c53ff6f9abd /lib
parent3f4b1cb5884531acae332cddba0ed3d647424567 (diff)
downloadpublic-inbox-dc890423db7c63c07ab248309accb429df405576.tar.gz
This will make some of our tests faster and allow users to try
more features of lei without high storage requirements.
Diffstat (limited to 'lib')
-rw-r--r--lib/PublicInbox/LeiSearch.pm8
-rw-r--r--lib/PublicInbox/LeiTag.pm10
-rw-r--r--lib/PublicInbox/LeiToMail.pm4
3 files changed, 17 insertions, 5 deletions
diff --git a/lib/PublicInbox/LeiSearch.pm b/lib/PublicInbox/LeiSearch.pm
index c2b12146..fb19229f 100644
--- a/lib/PublicInbox/LeiSearch.pm
+++ b/lib/PublicInbox/LeiSearch.pm
@@ -63,7 +63,9 @@ sub content_key ($) {
 }
 
 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 @@ sub xoids_for {
         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 @@ sub xoids_for {
                                 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 c650e886..b6abd533 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 @@ sub input_eml_cb { # used by PublicInbox::LeiInput::input_fh
         }
 }
 
-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 note_missing {
 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($$, \&note_missing, $self);
 }
diff --git a/lib/PublicInbox/LeiToMail.pm b/lib/PublicInbox/LeiToMail.pm
index da3a95d2..0cbdff8b 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;