about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-10-27 22:21:16 +0000
committerEric Wong <e@80x24.org>2023-10-28 09:08:20 +0000
commit9b3f8fc1d57dde120fa94d460d8cfbfdc07b7048 (patch)
tree4d6b15f69cf18ef0305a4c0de2e5d6df87a2da80
parenta2cb4e607271e2c86988f69afc2fdaee815fd381 (diff)
downloadpublic-inbox-9b3f8fc1d57dde120fa94d460d8cfbfdc07b7048.tar.gz
Just things I spotted while looking for other problems
throughout our codebase.
-rw-r--r--lib/PublicInbox/LeiALE.pm24
1 files changed, 11 insertions, 13 deletions
diff --git a/lib/PublicInbox/LeiALE.pm b/lib/PublicInbox/LeiALE.pm
index b198af1c..674d897e 100644
--- a/lib/PublicInbox/LeiALE.pm
+++ b/lib/PublicInbox/LeiALE.pm
@@ -1,4 +1,4 @@
-# Copyright (C) 2021 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 
 # All Locals Ever: track lei/store + externals ever used as
@@ -6,10 +6,10 @@
 # and --only targets that haven't been through "lei add-external".
 # Typically: ~/.cache/lei/all_locals_ever.git
 package PublicInbox::LeiALE;
-use strict;
-use v5.10.1;
+use v5.12;
 use parent qw(PublicInbox::LeiSearch PublicInbox::Lock);
 use PublicInbox::Git qw(read_all);
+use autodie qw(close open rename seek truncate);
 use PublicInbox::Import;
 use PublicInbox::LeiXSearch;
 use Fcntl qw(SEEK_SET);
@@ -77,18 +77,16 @@ sub refresh_externals {
         if ($new ne '' || $gone) {
                 $self->{lockfh}->autoflush(1);
                 if ($gone) {
-                        seek($self->{lockfh}, 0, SEEK_SET) or die "seek: $!";
-                        truncate($self->{lockfh}, 0) or die "truncate: $!";
+                        seek($self->{lockfh}, 0, SEEK_SET);
+                        truncate($self->{lockfh}, 0);
                 } else {
                         $old = '';
                 }
                 print { $self->{lockfh} } $old, $new or die "print: $!";
         }
-        $new = $old = '';
+        $new = '';
         my $f = $self->git->{git_dir}.'/objects/info/alternates';
-        if (open my $fh, '<', $f) {
-                read_all($fh, -s $fh, \$old);
-        }
+        $old = PublicInbox::Git::try_cat($f);
         for my $x (@ibxish) {
                 $new .= $lei->canonpath_harder($x->git->{git_dir})."/objects\n";
         }
@@ -98,10 +96,10 @@ sub refresh_externals {
         # this needs to be atomic since child processes may start
         # git-cat-file at any time
         my $tmp = "$f.$$.tmp";
-        open my $fh, '>', $tmp or die "open($tmp): $!";
-        print $fh $new or die "print($tmp): $!";
-        close $fh or die "close($tmp): $!";
-        rename($tmp, $f) or die "rename($tmp, $f): $!";
+        open my $fh, '>', $tmp;
+        print $fh $new;
+        close $fh;
+        rename($tmp, $f)
 }
 
 1;