]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
v2writable: hoist out process_todo sub for extindex
authorEric Wong <e@80x24.org>
Fri, 10 Jan 2025 23:20:12 +0000 (23:20 +0000)
committerEric Wong <e@80x24.org>
Tue, 14 Jan 2025 04:45:44 +0000 (04:45 +0000)
We can have consistent $self->{quit} detection this way and
eliminate an early return from index_todo.

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

index 6c578b3b6bfcb70b3f1bc7cb563a9cc25b56114c..807666fc89f47878c93e74596ef551ab10fc58e3 100644 (file)
@@ -417,10 +417,7 @@ sub _sync_inbox ($$$) {
        } else {
                return "E: $ekey unsupported inbox version (v$v)";
        }
-       for my $unit (@{delete($self->{todo}) // []}) {
-               last if $self->{quit};
-               index_todo($self, $sync, $unit);
-       }
+       PublicInbox::V2Writable::process_todo $self, $sync;
        $self->{midx}->index_ibx($ibx) unless $self->{quit};
        $ibx->git->cleanup; # done with this inbox, now
        undef;
index 072542cb03256f96c4fc4718daa23208bda28627..548d8bde013d5f014fa0956da595d2a9c8bf9394 100644 (file)
@@ -1122,7 +1122,6 @@ sub index_xap_step ($$$$;$) {
 
 sub index_todo ($$$) {
        my ($self, $sync, $unit) = @_;
-       return if $self->{quit};
        unindex_todo($self, $sync, $unit);
        my $stk = delete($unit->{stack}) or return;
        my $all = $self->git; # initialize self->{ibx}->{git}
@@ -1195,6 +1194,14 @@ sub xapian_only ($;$$) {
        $self->done;
 }
 
+sub process_todo ($$) {
+       my ($self, $sync) = @_;
+       for my $unit (@{delete($self->{todo}) // []}) {
+               last if $self->{quit};
+               $self->index_todo($sync, $unit); # may be ExtSearchIdx
+       }
+}
+
 # public, called by public-inbox-index
 sub index_sync {
        my ($self, $opt) = @_;
@@ -1252,7 +1259,7 @@ sub index_sync {
                }
        }
        # work forwards through history
-       index_todo($self, $sync, $_) for @{delete($self->{todo}) // []};
+       process_todo $self, $sync;
        $self->{oidx}->rethread_done($opt) unless $self->{quit};
        $self->done;