]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/InboxWritable.pm
update copyrights for 2021
[public-inbox.git] / lib / PublicInbox / InboxWritable.pm
index 69275bb04a54b9c476089b2f27e1a47bbb561385..982ad6e59d6afc43c265c0b4e454878985238094 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2018-2020 all contributors <meta@public-inbox.org>
+# Copyright (C) 2018-2021 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 
 # Extends read-only Inbox for writing
@@ -65,7 +65,6 @@ sub init_inbox {
        if ($self->version == 1) {
                my $dir = assert_usable_dir($self);
                PublicInbox::Import::init_bare($dir);
-               $self->umask_prepare;
                $self->with_umask(\&_init_v1, $self, $skip_artnum);
        } else {
                my $v2w = importer($self);
@@ -260,7 +259,7 @@ sub _umask_for {
 
 sub with_umask {
        my ($self, $cb, @arg) = @_;
-       my $old = umask $self->{umask};
+       my $old = umask($self->{umask} //= umask_prepare($self));
        my $rv = eval { $cb->(@arg) };
        my $err = $@;
        umask $old;
@@ -271,8 +270,7 @@ sub with_umask {
 sub umask_prepare {
        my ($self) = @_;
        my $perm = _git_config_perm($self);
-       my $umask = _umask_for($perm);
-       $self->{umask} = $umask;
+       _umask_for($perm);
 }
 
 sub cleanup ($) {
@@ -294,7 +292,7 @@ sub warn_ignore {
 
 # this expects to be RHS in this assignment: "local $SIG{__WARN__} = ..."
 sub warn_ignore_cb {
-       my $cb = $SIG{__WARN__} // sub { print STDERR @_ };
+       my $cb = $SIG{__WARN__} // \&CORE::warn;
        sub {
                return if warn_ignore(@_);
                $cb->(@_);