diff options
author | Eric Wong <e@80x24.org> | 2023-10-17 23:37:52 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2023-10-18 20:50:24 +0000 |
commit | 19b791f4894efcb6e545a6b51c8147298363358f (patch) | |
tree | 16a806fcb0c8fdaef242a2d268a8b1416809b46f /lib/PublicInbox/LeiSucks.pm | |
parent | 35b0f7aa00a24f5d89b1b941ec644327ba074c99 (diff) | |
download | public-inbox-19b791f4894efcb6e545a6b51c8147298363358f.tar.gz |
`readline' ops may not detect errors on partial reads. This saves us some code to reduce cognitive overhead for readers. We'll also support reusing a destination buffers so it can work more nicely with existing code.
Diffstat (limited to 'lib/PublicInbox/LeiSucks.pm')
-rw-r--r-- | lib/PublicInbox/LeiSucks.pm | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/PublicInbox/LeiSucks.pm b/lib/PublicInbox/LeiSucks.pm index 35d0a8de..82aea8d4 100644 --- a/lib/PublicInbox/LeiSucks.pm +++ b/lib/PublicInbox/LeiSucks.pm @@ -12,6 +12,7 @@ use Config; use POSIX (); use PublicInbox::Config; use PublicInbox::IPC; +use PublicInbox::Git qw(read_all); sub lei_sucks { my ($lei, @argv) = @_; @@ -58,8 +59,8 @@ sub lei_sucks { for my $m (grep(m{^PublicInbox/}, sort keys %INC)) { my $f = $INC{$m} // next; # lazy require failed (missing dep) open my $fh, '<', $f or do { warn "open($f): $!"; next }; - my $hex = sha1_hex('blob '.(-s $fh)."\0". - (do { local $/; <$fh> } // die("read: $!"))); + my $size = -s $fh; + my $hex = sha1_hex("blob $size\0".read_all($fh, $size)); push @out, ' '.$hex.' '.$m."\n"; } push @out, <<'EOM'; |