- $self->idx_init; # reacquire lock
- $sync->{mm_tmp}->atfork_parent;
-}
-
-# only for a few odd messages with multiple Message-IDs
-sub reindex_oid_m ($$$$;$) {
- my ($self, $sync, $git, $oid, $regen_num) = @_;
- $self->{current_info} = "multi_mid $oid";
- my ($num, $mid0, $len);
- my $msgref = $git->cat_file($oid, \$len);
- my $mime = PublicInbox::MIME->new($$msgref);
- my $mids = mids($mime->header_obj);
- my $cid = content_id($mime);
- die "BUG: reindex_oid_m called for <=1 mids" if scalar(@$mids) <= 1;
-
- for my $mid (reverse @$mids) {
- delete($sync->{D}->{"$mid\0$cid"}) and
- die "BUG: reindex_oid should handle <$mid> delete";
- }
- my $over = $self->{over};
- for my $mid (reverse @$mids) {
- ($num, $mid0) = $over->num_mid0_for_oid($oid, $mid);
- next unless defined $num;
- if (defined($regen_num) && $regen_num != $num) {
- die "BUG: regen(#$regen_num) != over(#$num)";
- }
- }
- unless (defined($num)) {
- for my $mid (reverse @$mids) {
- # is this a number we got before?
- my $n = $sync->{mm_tmp}->num_for($mid);
- next unless defined $n;
- next if defined($regen_num) && $regen_num != $n;
- ($num, $mid0) = ($n, $mid);
- last;
- }
- }
- if (defined($num)) {
- $sync->{mm_tmp}->num_delete($num);
- } elsif (defined $regen_num) {
- $num = $regen_num;
- for my $mid (reverse @$mids) {
- $self->{mm}->mid_set($num, $mid) == 1 or next;
- $mid0 = $mid;
- last;
- }
- unless (defined $mid0) {
- warn "E: cannot regen #$num\n";
- return;
- }
- } else { # fixup bugs in old mirrors on reindex
- for my $mid (reverse @$mids) {
- $num = $self->{mm}->mid_insert($mid);
- next unless defined $num;
- $mid0 = $mid;
- last;
- }
- if (defined $mid0) {
- if ($sync->{reindex}) {
- warn "reindex added #$num <$mid0>\n";
- }
- } else {
- warn "E: cannot find article #\n";
- return;
- }
- }
- $sync->{nr}++;
- if (do_idx($self, $msgref, $mime, $len, $num, $oid, $mid0)) {
- reindex_checkpoint($self, $sync, $git);
- }