- $sync->{nr}++;
- my $smsg = bless {
- bytes => $len,
- num => $num,
- blob => $oid,
- mid => $mid0,
- }, 'PublicInbox::Smsg';
- if (do_idx($self, $msgref, $mime, $smsg)) {
- reindex_checkpoint($self, $sync, $git);
- }
-}
-
-sub check_unindexed ($$$) {
- my ($self, $num, $mid0) = @_;
- my $unindexed = $self->{unindexed} // {};
- my $n = delete($unindexed->{$mid0});
- defined $n or return;
- if ($n != $num) {
- die "BUG: unindexed $n != $num <$mid0>\n";
- } else {
- $self->{mm}->mid_set($num, $mid0);
- }
-}
-
-sub multi_mid_q_push ($$$) {
- my ($self, $sync, $oid) = @_;
- my $multi_mid = $sync->{multi_mid} //= PublicInbox::MultiMidQueue->new;
- if ($sync->{reindex}) { # no regen on reindex
- $multi_mid->push_oid($oid, $self);
- } else {
- my $num = $sync->{regen}--;
- die "BUG: ran out of article numbers" if $num <= 0;
- $multi_mid->set_oid($num, $oid, $self);
- }
-}
-
-sub reindex_oid ($$$$) {
- my ($self, $sync, $git, $oid) = @_;
- return if PublicInbox::SearchIdx::too_big($self, $git, $oid);
- my ($num, $mid0, $len);
- my $msgref = $git->cat_file($oid, \$len);
- return if $len == 0; # purged
- my $mime = PublicInbox::Eml->new($$msgref);
- my $mids = mids($mime->header_obj);
- my $cid = content_id($mime);
-
- if (scalar(@$mids) == 0) {
- warn "E: $oid has no Message-ID, skipping\n";
- return;
- } elsif (scalar(@$mids) == 1) {
- my $mid = $mids->[0];
-
- # was the file previously marked as deleted?, skip if so
- if (delete($sync->{D}->{"$mid\0$cid"})) {
- if (!$sync->{reindex}) {
- $num = $sync->{regen}--;
- $self->{mm}->num_highwater($num);
- }
- return;
- }
-
- # is this a number we got before?
- $num = $sync->{mm_tmp}->num_for($mid);
- if (defined $num) {
- $mid0 = $mid;
- check_unindexed($self, $num, $mid0);
- } else {
- $num = $sync->{regen}--;
- die "BUG: ran out of article numbers" if $num <= 0;
- if ($self->{mm}->mid_set($num, $mid) != 1) {
- warn "E: unable to assign $num => <$mid>\n";
- return;