]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
multi_git: use autodie
authorEric Wong <e@80x24.org>
Thu, 2 Nov 2023 09:35:31 +0000 (09:35 +0000)
committerEric Wong <e@80x24.org>
Fri, 3 Nov 2023 06:39:28 +0000 (06:39 +0000)
Trying to move away from half my code being "or die" statements...

lib/PublicInbox/MultiGit.pm

index 9074758a77449ad0ce0c2288999280fa07684859..1e8eb47a5626a235fc23a3f16f3c5e6adbe70c22 100644 (file)
@@ -10,6 +10,7 @@ use PublicInbox::Import;
 use File::Temp 0.19;
 use List::Util qw(max);
 use PublicInbox::Git qw(read_all);
+use autodie qw(chmod close rename);
 
 sub new {
        my ($cls, $topdir, $all, $epfx) = @_;
@@ -68,12 +69,10 @@ sub write_alternates {
        my $out = join('', sort { $alt->{$b} <=> $alt->{$a} } keys %$alt);
        my $info_dir = "$all_dir/objects/info";
        my $fh = File::Temp->new(TEMPLATE => 'alt-XXXX', DIR => $info_dir);
-       my $f = $fh->filename;
-       print $fh $out, @new or die "print($f): $!";
-       chmod($mode, $fh) or die "fchmod($f): $!";
-       close $fh or die "close($f): $!";
-       my $fn = "$info_dir/alternates";
-       rename($f, $fn) or die "rename($f, $fn): $!";
+       print $fh $out, @new;
+       chmod($mode, $fh);
+       close $fh;
+       rename($fh->filename, "$info_dir/alternates");
        $fh->unlink_on_destroy(0);
 }