]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/LeiStore.pm
viewvcs: add path name hint based on `b=' query param
[public-inbox.git] / lib / PublicInbox / LeiStore.pm
index 8e710540f0345cc27f5aa127c60801df32523f70..0ecf138876e4faa4e88d5615790b77a6aa331ad5 100644 (file)
@@ -344,6 +344,15 @@ sub _reindex_1 { # git->cat_async callback
                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");
        }
@@ -595,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 (via awaitpid_init)
+       my ($pid, $sto) = @_;
        warn "lei/store PID:$pid died \$?=$?\n" if $?;
 }
 
@@ -612,12 +620,12 @@ sub write_prepare {
                # Mail we import into lei are private, so headers filtered out
                # by -mda for public mail are not appropriate
                local @PublicInbox::MDA::BAD_HEADERS = ();
+               $self->awaitpid_init(\&_sto_atexit); # outlives $lei
                $self->wq_workers_start("lei/store $dir", 1, $lei->oldset, {
                                        lei => $lei,
                                        -err_wr => $w,
                                        to_close => [ $r ],
                                });
-               $self->wq_wait_async(\&_sto_atexit); # outlives $lei
                require PublicInbox::LeiStoreErr;
                PublicInbox::LeiStoreErr->new($r, $lei);
        }