about summary refs log tree commit homepage
path: root/script/public-inbox-init
diff options
authorEric Wong <e@yhbt.net>2020-08-10 02:11:58 +0000
committerEric Wong <e@yhbt.net>2020-08-10 05:56:07 +0000
commit67380a130f18b5b3abbee82346ff7c15185f41e8 (patch)
tree98c68c6cc8d6d9aec7fd5216f48e70af93303bd7 /script/public-inbox-init
parent6f9a86728b98887ae0d76234afb2679b6f6dd4ae (diff)
We can use open(..., undef) natively in Perl in t/import.t

In places where we need a pathname, the File::Temp OO API
gives us auto-unlinking for free.
Diffstat (limited to 'script/public-inbox-init')
1 files changed, 4 insertions, 5 deletions
diff --git a/script/public-inbox-init b/script/public-inbox-init
index b8d71f35..6a959db7 100755
--- a/script/public-inbox-init
+++ b/script/public-inbox-init
@@ -17,7 +17,7 @@ PublicInbox::Admin::require_or_die('-base');
 use PublicInbox::Config;
 use PublicInbox::InboxWritable;
 use PublicInbox::Import;
-use File::Temp qw/tempfile/;
+use File::Temp;
 use PublicInbox::Lock;
 use File::Basename qw/dirname/;
 use File::Path qw/mkpath/;
@@ -52,8 +52,7 @@ my $lock_obj = { lock_path => "$pi_config.flock" };
 # git-config will operate on this (and rename on success):
-my ($fh, $pi_config_tmp) = tempfile('pi-init-XXXXXXXX', DIR => $dir);
-my $cfg_tmp = UnlinkMe->new($pi_config_tmp);
+my $fh = File::Temp->new(TEMPLATE => 'pi-init-XXXXXXXX', DIR => $dir);
 # Now, we grab another lock to use git-config(1) locking, so it won't
 # wait on the lock, unlike some of our internal flock()-based locks.
@@ -110,7 +109,8 @@ if (-e $pi_config) {
-close $fh or die "failed to close $pi_config_tmp: $!\n";
+my $pi_config_tmp = $fh->filename;
+close($fh) or die "failed to close $pi_config_tmp: $!\n";
 my $pfx = "publicinbox.$name";
 my @x = (qw/git config/, "--file=$pi_config_tmp");
@@ -177,7 +177,6 @@ if (defined $perm) {
 rename $pi_config_tmp, $pi_config or
         die "failed to rename `$pi_config_tmp' to `$pi_config': $!\n";
-delete $cfg_tmp->{file};
 package UnlinkMe;