]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
(ext)index: eliminate $sync->{ibx}
authorEric Wong <e@80x24.org>
Fri, 10 Jan 2025 23:20:59 +0000 (23:20 +0000)
committerEric Wong <e@80x24.org>
Tue, 14 Jan 2025 04:45:49 +0000 (04:45 +0000)
Perhaps the trickiest field to eliminate from $sync {ibx}
due to the way -extindex handles cross-posted messages.  We
now eliminate the per-request $req->{ibx} for non-crossposted
messages and use local-ized $self->{ibx} directly.

lib/PublicInbox/ExtSearchIdx.pm
lib/PublicInbox/V2Writable.pm

index c0eae0e3c652663ce57e728cde0708e4c3fe015f..946f5a4b38c1e38ed95454634b127e7e4b4f91c6 100644 (file)
@@ -223,7 +223,7 @@ sub do_xpost ($$) {
        my $self = $req->{self};
        my $docid = $smsg->{num};
        my $oid = $req->{oid};
-       my $xibx = $req->{ibx};
+       my $xibx = $req->{ibx} // $self->{ibx};
        my $eml = $req->{eml};
        if (my $new_smsg = $req->{new_smsg}) { # 'm' on cross-posted message
                my $eidx_key = $xibx->eidx_key;
@@ -253,7 +253,7 @@ sub index_unseen ($) {
        my $idx = $self->idx_shard($docid);
        $self->{oidx}->add_overview($eml, $new_smsg);
        my $oid = $new_smsg->{blob};
-       my $ibx = delete $req->{ibx} or die 'BUG: {ibx} unset';
+       my $ibx = ($req->{ibx} // $self->{ibx}) or die 'BUG: {ibx} unset';
        my $ekey = $new_smsg->{eidx_key} = $ibx->eidx_key;
        $self->{oidx}->add_xref3($docid, $req->{xnum}, $oid, $ekey);
        $idx->index_eml($eml, $new_smsg);
@@ -326,8 +326,8 @@ sub ck_existing { # git->cat_async callback
 # return the number if so
 sub cur_ibx_xnum ($$;$) {
        my ($req, $bref, $mismatch) = @_;
-       my $ibx = $req->{ibx} or die 'BUG: current {ibx} missing';
-
+       my $ibx = ($req->{ibx} // $req->{self}->{ibx}) or
+               die 'BUG: current {ibx} missing';
        $req->{eml} = PublicInbox::Eml->new($bref);
        $req->{chash} = content_hash($req->{eml});
        $req->{mids} = mids($req->{eml});
@@ -397,7 +397,6 @@ sub _sync_inbox ($$$) {
        if (defined(my $err = _ibx_index_reject($ibx))) {
                return "W: skipping $ekey ($err)";
        }
-       $sync->{ibx} = $ibx; # FIXME: eliminate
        local $self->{ibx} = $ibx;
        $self->{nrec} = 0;
        local $self->{epoch_max};
index ded3f2c1f1b27ec03b0b10e445ff06e999935d4f..80ee346d06cd4d5d2bfec470c9b9f94eb90e0746 100644 (file)
@@ -1237,7 +1237,7 @@ sub index_sync {
        local $self->{todo}; # sync_prepare
        local $self->{ranges};
        local $self->{unindexed};
-       my $sync = { self => $self, ibx => $self->{ibx} };
+       my $sync = { self => $self };
        my $quit = PublicInbox::SearchIdx::quit_cb $self;
        local $SIG{QUIT} = $quit;
        local $SIG{INT} = $quit;