about summary refs log tree commit homepage
path: root/lib/PublicInbox/SearchIdx.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-04-07 12:40:51 +0000
committerEric Wong <e@80x24.org>2023-04-07 22:17:21 +0000
commit39b99c2514230f419fae8c2b52a7d55eaad1cd44 (patch)
tree9fd91da5f74839b307bfc42147f797849bc46be3 /lib/PublicInbox/SearchIdx.pm
parent1fc59b952c8e9618abad4ec52888e43f55b8ab77 (diff)
downloadpublic-inbox-39b99c2514230f419fae8c2b52a7d55eaad1cd44.tar.gz
This lets us get rid of some awkwardness around the old API
and single-use subroutines while saving us some LoC.
Diffstat (limited to 'lib/PublicInbox/SearchIdx.pm')
-rw-r--r--lib/PublicInbox/SearchIdx.pm19
1 files changed, 6 insertions, 13 deletions
diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm
index 69ab30e6..511dd4d6 100644
--- a/lib/PublicInbox/SearchIdx.pm
+++ b/lib/PublicInbox/SearchIdx.pm
@@ -1110,8 +1110,10 @@ sub DESTROY {
         $_[0]->{lockfh} = undef;
 }
 
-sub _begin_txn {
+sub begin_txn_lazy {
         my ($self) = @_;
+        return if $self->{txn};
+        my $restore = $self->with_umask;
         my $xdb = $self->{xdb} || idx_acquire($self);
         $self->{oidx}->begin_lazy if $self->{oidx};
         $xdb->begin_transaction if $xdb;
@@ -1119,11 +1121,6 @@ sub _begin_txn {
         $xdb;
 }
 
-sub begin_txn_lazy {
-        my ($self) = @_;
-        $self->with_umask(\&_begin_txn, $self) if !$self->{txn};
-}
-
 # store 'indexlevel=medium' in v2 shard=0 and v1 (only one shard)
 # This metadata is read by InboxWritable->detect_indexlevel:
 sub set_metadata_once {
@@ -1147,8 +1144,10 @@ sub set_metadata_once {
         }
 }
 
-sub _commit_txn {
+sub commit_txn_lazy {
         my ($self) = @_;
+        return unless delete($self->{txn});
+        my $restore = $self->with_umask;
         if (my $eidx = $self->{eidx}) {
                 $eidx->git->async_wait_all;
                 $eidx->{transact_bytes} = 0;
@@ -1160,12 +1159,6 @@ sub _commit_txn {
         $self->{oidx}->commit_lazy if $self->{oidx};
 }
 
-sub commit_txn_lazy {
-        my ($self) = @_;
-        delete($self->{txn}) and
-                $self->with_umask(\&_commit_txn, $self);
-}
-
 sub eidx_shard_new {
         my ($class, $eidx, $shard) = @_;
         my $self = bless {