From 9d8a15fdb93e3a32f73169f827953c69c5ff251e Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 25 Oct 2023 06:33:55 +0000 Subject: lei_mirror+fetch: don't slurp `git show-ref' output While uncommon, some git repos have hundreds of thousands of refs and slurping that output into memory can bloat the heap. Introduce a sha_all sub in PublicInbox::SHA to loop until EOF and rely on autodie for checking sysread errors. --- lib/PublicInbox/Fetch.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/PublicInbox/Fetch.pm') diff --git a/lib/PublicInbox/Fetch.pm b/lib/PublicInbox/Fetch.pm index 6e9b1e94..e41dd448 100644 --- a/lib/PublicInbox/Fetch.pm +++ b/lib/PublicInbox/Fetch.pm @@ -10,6 +10,7 @@ use PublicInbox::Admin; use PublicInbox::LEI; use PublicInbox::LeiCurl; use PublicInbox::LeiMirror; +use PublicInbox::SHA qw(sha_all); use File::Temp (); sub new { bless {}, __PACKAGE__ } @@ -92,9 +93,8 @@ sub do_manifest ($$$) { sub get_fingerprint2 { my ($git_dir) = @_; - require PublicInbox::SHA; my $rd = popen_rd([qw(git show-ref)], undef, { -C => $git_dir }); - PublicInbox::SHA::sha256(do { local $/; <$rd> }); + sha_all(256, $rd)->digest; # ignore show-ref errors } sub writable_dir ($) { -- cgit v1.2.3-24-ge0c7