From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id AEA7F215F4 for ; Tue, 1 May 2018 01:51:41 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] searchidx: preserve umask when starting/committing transactions Date: Tue, 1 May 2018 01:51:41 +0000 Message-Id: <20180501015141.9932-1-e@80x24.org> List-Id: Xapian will replace files upon committing, so non-parallel V2Writable users need to have umask preserved this way. --- lib/PublicInbox/SearchIdx.pm | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm index aeb363e..74f9267 100644 --- a/lib/PublicInbox/SearchIdx.pm +++ b/lib/PublicInbox/SearchIdx.pm @@ -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 { -- EW