From: Eric Wong Date: Fri, 10 Jan 2025 23:18:58 +0000 (+0000) Subject: (ext)index: move {max_size} and related bits to $self X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=922b765d06af32f57b064e23a881109e536a1eeb;p=thirdparty%2Fpublic-inbox.git (ext)index: move {max_size} and related bits to $self `--max-size' is persistent for a process, so having it in $self is more appropriate anyways than the shorter-lived $sync. The {index_oid} function pointer is tied to max-size handling, so we'll move that over to $self as well. --- diff --git a/lib/PublicInbox/ExtSearchIdx.pm b/lib/PublicInbox/ExtSearchIdx.pm index 2f6de2bbd..ebcc8770e 100644 --- a/lib/PublicInbox/ExtSearchIdx.pm +++ b/lib/PublicInbox/ExtSearchIdx.pm @@ -397,7 +397,8 @@ sub _sync_inbox ($$$) { if (defined(my $err = _ibx_index_reject($ibx))) { return "W: skipping $ekey ($err)"; } - $sync->{ibx} = $ibx; + $sync->{ibx} = $ibx; # FIXME: eliminate + local $self->{ibx} = $ibx; $self->{nrec} = 0; my $v = $ibx->version; if ($v == 2) { diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm index 24f76c329..9771633d5 100644 --- a/lib/PublicInbox/SearchIdx.pm +++ b/lib/PublicInbox/SearchIdx.pm @@ -849,12 +849,13 @@ sub index_sync { sub check_size { # check_async cb for -index --max-size=... my (undef, $oid, $type, $size, $arg) = @_; + my $self = $arg->{self}; ($type // '') eq 'blob' or - die "E: bad $oid in $arg->{ibx}->{git}->{git_dir}"; - if ($size <= $arg->{max_size}) { - $arg->{ibx}->{git}->cat_async($oid, $arg->{index_oid}, $arg); + die "E: bad $oid in $self->{ibx}->{git}->{git_dir}"; + if ($size <= $self->{max_size}) { + $self->{ibx}->{git}->cat_async($oid, $self->{index_oid}, $arg); } else { - warn "W: skipping $oid ($size > $arg->{max_size})\n"; + warn "W: skipping $oid ($size > $self->{max_size})\n"; } } @@ -921,16 +922,15 @@ sub v1_process_stack ($$$) { $git->cat_async($oid, \&v1_unindex_both, $sync); } } - if ($sync->{max_size} = $self->{-opt}->{max_size}) { - $sync->{index_oid} = \&v1_index_both; - } + $self->{max_size} = $self->{-opt}->{max_size} and + $self->{index_oid} = \&v1_index_both; while (my ($f, $at, $ct, $oid, $cur_cmt) = $stk->pop_rec) { my $arg = { %$sync, cur_cmt => $cur_cmt, oid => $oid }; last if $self->{quit}; if ($f eq 'm') { $arg->{autime} = $at; $arg->{cotime} = $ct; - if ($sync->{max_size}) { + if ($self->{max_size}) { $git->check_async($oid, \&check_size, $arg); } else { $git->cat_async($oid, \&v1_index_both, $arg); diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm index 886f59b11..ff4e973a1 100644 --- a/lib/PublicInbox/V2Writable.pm +++ b/lib/PublicInbox/V2Writable.pm @@ -935,9 +935,8 @@ sub sync_prepare ($$) { # rerun index_sync without {reindex} $reindex_heads = $self->last_commits($sync); } - if ($sync->{max_size} = $self->{-opt}->{max_size}) { - $sync->{index_oid} = $self->can('index_oid'); - } + $self->{max_size} = $self->{-opt}->{max_size} and + $self->{index_oid} = $self->can('index_oid'); my $git_pfx = "$sync->{ibx}->{inboxdir}/git"; for (my $i = $sync->{epoch_max}; $i >= 0; $i--) { my $git_dir = "$git_pfx/$i.git"; @@ -1154,7 +1153,7 @@ sub index_todo ($$$) { cur_cmt => $cmt }; if ($f eq 'm') { - if ($sync->{max_size}) { + if ($self->{max_size}) { $all->check_async($oid, \&check_size, $req); } else { $all->cat_async($oid, $index_oid, $req);