]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
git: rely on autodie for sysseek/sysread/truncate
authorEric Wong <e@80x24.org>
Sat, 18 Jan 2025 01:26:12 +0000 (01:26 +0000)
committerEric Wong <e@80x24.org>
Tue, 21 Jan 2025 22:37:01 +0000 (22:37 +0000)
Error messages are more consistent with autodie.  We'll also
drop autodie::read since it's no longer in use for this package.

lib/PublicInbox/Git.pm

index b3f39adf832774f1350c991c2131f948f055d35f..9e0840ab5cbf0b426ce06ccaef69787d2802bf34 100644 (file)
@@ -11,8 +11,8 @@ use strict;
 use v5.10.1;
 use parent qw(Exporter PublicInbox::DS);
 use PublicInbox::DS qw(now);
-use autodie qw(socketpair read);
-use POSIX ();
+use autodie qw(socketpair sysread sysseek truncate);
+use POSIX qw(SEEK_SET);
 use Socket qw(AF_UNIX SOCK_STREAM);
 use PublicInbox::Syscall qw(EPOLLIN EPOLLET);
 use Errno qw(EAGAIN);
@@ -145,11 +145,13 @@ sub object_format {
 sub last_check_err {
        my ($self) = @_;
        my $fh = $self->{err_c} or return '';
-       sysseek($fh, 0, 0) or $self->fail("sysseek: $!");
        my $size = -s $fh or return '';
-       sysread($fh, my $buf, $size) // $self->fail("sysread: $!");
-       truncate($fh, 0) or $self->fail("truncate: $!");
-       $buf;
+       eval {
+               sysseek $fh, 0, SEEK_SET;
+               sysread($fh, my $buf, $size);
+               truncate $fh, 0;
+               $buf;
+       } // $self->fail($@);
 }
 
 sub gcf_drain { # awaitpid cb