]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/LeiStore.pm
lei q: do not collapse threads with `-tt'
[public-inbox.git] / lib / PublicInbox / LeiStore.pm
index 277ed6bdaed7b646325e15bb9871ef0736363aae..fce15a724b511d15c49a3a2c196eb4d9e68291d7 100644 (file)
@@ -337,12 +337,22 @@ sub _docids_and_maybe_kw ($$) {
 
 sub _reindex_1 { # git->cat_async callback
        my ($bref, $hex, $type, $size, $smsg) = @_;
-       my ($self, $eidx, $tl) = delete @$smsg{qw(-self -eidx -tl)};
+       my $self = delete $smsg->{-sto};
+       my ($eidx, $tl) = eidx_init($self);
        $bref //= _lms_rw($self)->local_blob($hex, 1);
        if ($bref) {
                my $eml = PublicInbox::Eml->new($bref);
                $smsg->{-merge_vmd} = 1; # preserve existing keywords
                $eidx->idx_shard($smsg->{num})->index_eml($eml, $smsg);
+       } elsif ($type eq 'missing') {
+               # pre-release/buggy lei may've indexed external-only msgs,
+               # try to correct that, here
+               warn("E: missing $hex, culling (ancient lei artifact?)\n");
+               $smsg->{to} = $smsg->{cc} = $smsg->{from} = '';
+               $smsg->{bytes} = 0;
+               $eidx->{oidx}->update_blob($smsg, '');
+               my $eml = PublicInbox::Eml->new("\r\n\r\n");
+               $eidx->idx_shard($smsg->{num})->index_eml($eml, $smsg);
        } else {
                warn("E: $type $hex\n");
        }
@@ -353,7 +363,7 @@ sub reindex_art {
        my ($eidx, $tl) = eidx_init($self);
        my $smsg = $eidx->{oidx}->get_art($art) // return;
        return if $smsg->{bytes} == 0; # external-only message
-       @$smsg{qw(-self -eidx -tl)} = ($self, $eidx, $tl);
+       $smsg->{-sto} = $self;
        $eidx->git->cat_async($smsg->{blob} // die("no blob (#$art)"),
                                \&_reindex_1, $smsg);
 }
@@ -594,9 +604,8 @@ sub recv_and_run {
        $self->SUPER::recv_and_run(@args);
 }
 
-sub _sto_atexit { # dwaitpid callback
-       my ($args, $pid) = @_;
-       my $self = $args->[0];
+sub _sto_atexit { # awaitpid cb
+       my ($pid) = @_;
        warn "lei/store PID:$pid died \$?=$?\n" if $?;
 }
 
@@ -615,8 +624,7 @@ sub write_prepare {
                                        lei => $lei,
                                        -err_wr => $w,
                                        to_close => [ $r ],
-                               });
-               $self->wq_wait_async(\&_sto_atexit); # outlives $lei
+                               }, \&_sto_atexit);
                require PublicInbox::LeiStoreErr;
                PublicInbox::LeiStoreErr->new($r, $lei);
        }