]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
searchidx: update_checkpoint: take bytes arg directly
authorEric Wong <e@80x24.org>
Thu, 12 Dec 2024 10:10:38 +0000 (10:10 +0000)
committerEric Wong <e@80x24.org>
Fri, 13 Dec 2024 19:58:09 +0000 (19:58 +0000)
Passing $smsg limits flexibility in case we reuse it for deletes
and/or commit search.

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

index fe2f5d2e47d4f6e6269c8b9ed186076057ba04d1..1c2a9a26d3d74b53240490f011e22b1e2c7cabdc 100644 (file)
@@ -125,7 +125,7 @@ sub attach_config {
 sub check_batch_limit ($) {
        my ($req) = @_;
        # set flag for PublicInbox::V2Writable::index_todo:
-       update_checkpoint $req->{self}, $req->{new_smsg} and
+       update_checkpoint $req->{self}, $req->{new_smsg}->{bytes} and
                ${$req->{need_checkpoint}} = 1;
 }
 
index 3a85f55210e94f0307a1176148e4de364e5c399b..0d9acd20b28d41b6f7e6bacabc9aaedc8f45b3a4 100644 (file)
@@ -788,8 +788,8 @@ sub is_bad_blob ($$$$) {
 }
 
 sub update_checkpoint ($$) {
-       my ($self, $smsg) = @_;
-       ($self->{transact_bytes} += $smsg->{bytes}) >= $self->{batch_bytes} and
+       my ($self, $bytes) = @_;
+       ($self->{transact_bytes} += $bytes) >= $self->{batch_bytes} and
                return 1;
        my $now = now;
        my $next = $self->{next_checkpoint} //= $now + $CHECKPOINT_INTVL;
@@ -803,7 +803,7 @@ sub index_both { # git->cat_async callback
        my $smsg = bless { blob => $oid }, 'PublicInbox::Smsg';
        $smsg->set_bytes($$bref, $size);
        my $self = $sync->{sidx};
-       ${$sync->{need_checkpoint}} = 1 if update_checkpoint $self, $smsg;
+       ${$sync->{need_checkpoint}} = 1 if update_checkpoint $self, $smsg->{bytes};
        local $self->{current_info} = "$self->{current_info}: $oid";
        my $eml = PublicInbox::Eml->new($bref);
        $smsg->{num} = index_mm($self, $eml, $oid, $sync) or
index 5f3bfde54b5cf96347dae95fa22fad1c4be405f3..c894b6482eb7549601218b8a6595aeff6cd24920 100644 (file)
@@ -107,7 +107,7 @@ sub do_idx ($$$) {
                my $idx = idx_shard($self, $smsg->{num});
                $idx->index_eml($eml, $smsg);
        }
-       update_checkpoint $self, $smsg;
+       update_checkpoint $self, $smsg->{bytes};
 }
 
 # returns undef on duplicate or spam