]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/SearchIdx.pm
searchidx: preserve umask when starting/committing transactions
[public-inbox.git] / lib / PublicInbox / SearchIdx.pm
index 4dc81352f535568d7673cabb8d6ad6fff5cb859b..74f9267ec0a8460e3a2eac40b2cb51967de78abd 100644 (file)
@@ -331,6 +331,13 @@ sub add_message {
 
                foreach my $mid (@$mids) {
                        $tg->index_text($mid, 1, 'XM');
+
+                       # because too many Message-IDs are prefixed with
+                       # "Pine.LNX."...
+                       if ($mid =~ /\w{12,}/) {
+                               my @long = ($mid =~ /(\w{3,}+)/g);
+                               $tg->index_text(join(' ', @long), 1, 'XM');
+                       }
                        $tg->increase_termpos;
                }
                $smsg->{to} = $smsg->{cc} = '';
@@ -745,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 {