]> Sergey Matveev's repositories - public-inbox.git/commitdiff
searchidx: preserve umask when starting/committing transactions
authorEric Wong <e@80x24.org>
Tue, 1 May 2018 01:51:41 +0000 (01:51 +0000)
committerEric Wong <e@80x24.org>
Tue, 1 May 2018 01:52:34 +0000 (01:52 +0000)
Xapian will replace files upon committing, so non-parallel
V2Writable users need to have umask preserved this way.

lib/PublicInbox/SearchIdx.pm

index aeb363e03d1d57a7ccd3cc7c1ae408cf98d91a05..74f9267ec0a8460e3a2eac40b2cb51967de78abd 100644 (file)
@@ -752,18 +752,23 @@ sub remote_remove {
 sub begin_txn_lazy {
        my ($self) = @_;
        return if $self->{txn};
-       my $xdb = $self->{xdb} || $self->_xdb_acquire;
-       $self->{over}->begin_lazy if $self->{over};
-       $xdb->begin_transaction;
-       $self->{txn} = 1;
-       $xdb;
+
+       $self->{-inbox}->with_umask(sub {
+               my $xdb = $self->{xdb} || $self->_xdb_acquire;
+               $self->{over}->begin_lazy if $self->{over};
+               $xdb->begin_transaction;
+               $self->{txn} = 1;
+               $xdb;
+       });
 }
 
 sub commit_txn_lazy {
        my ($self) = @_;
        delete $self->{txn} or return;
-       $self->{xdb}->commit_transaction;
-       $self->{over}->commit_lazy if $self->{over};
+       $self->{-inbox}->with_umask(sub {
+               $self->{xdb}->commit_transaction;
+               $self->{over}->commit_lazy if $self->{over};
+       });
 }
 
 sub worker_done {