From 8d86e5b49d7f5d6e0b1768d0bd55fd21df36f86e Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 2 Nov 2023 09:35:38 +0000 Subject: move read_all, try_cat, and poll_in to PublicInbox::IO The IO package seems like a better home for I/O subs than the Git package. We lose the 60 second read timeout for `git cat-file --batch-*' processes since it's probably not necessary given how reliable the code has proven and things would fall over hard in other ways if the storage device were completely hosed. --- script/public-inbox-convert | 2 +- script/public-inbox-edit | 3 +-- script/public-inbox-init | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) (limited to 'script') diff --git a/script/public-inbox-convert b/script/public-inbox-convert index d8186809..713c2881 100755 --- a/script/public-inbox-convert +++ b/script/public-inbox-convert @@ -131,7 +131,7 @@ while (<$rd>) { $state = 'commit'; } elsif (/^data ([0-9]+)/) { print $io $_ or $im->wfail; - print $io PublicInbox::Git::read_all($rd, $1) or $im->wfail; + print $io PublicInbox::IO::read_all($rd, $1) or $im->wfail; next; } elsif ($state eq 'commit') { if (m{^M 100644 :([0-9]+) (${h}{2}/${h}{38})}o) { diff --git a/script/public-inbox-edit b/script/public-inbox-edit index 77028817..88115d7c 100755 --- a/script/public-inbox-edit +++ b/script/public-inbox-edit @@ -15,7 +15,6 @@ PublicInbox::Admin::check_require('-index'); use PublicInbox::Eml; use PublicInbox::InboxWritable qw(eml_from_path); use PublicInbox::Import; -use PublicInbox::Git qw(read_all); my $help = <<'EOF'; usage: public-inbox-edit -m MESSAGE-ID [--all] [INBOX_DIRS] @@ -185,7 +184,7 @@ retry_edit: # rename/relink $edit_fn open my $new_fh, '<', $edit_fn or die "can't read edited file ($edit_fn): $!\n"; - my $new_raw = read_all($new_fh); + my $new_raw = PublicInbox::IO::read_all $new_fh; if (!$opt->{raw}) { PublicInbox::Eml::strip_from($new_raw); diff --git a/script/public-inbox-init b/script/public-inbox-init index 6420db7e..8915cf31 100755 --- a/script/public-inbox-init +++ b/script/public-inbox-init @@ -126,12 +126,12 @@ my $auto_unlink = PublicInbox::OnDestroy->new($$, sub { unlink $lockfile }); my $perm = 0644 & ~umask; my %seen; if (-e $pi_config) { - require PublicInbox::Git; + require PublicInbox::IO; open(my $oh, '<', $pi_config); my @st = stat($oh) or die "(f)stat failed on $pi_config: $!\n"; $perm = $st[2]; chmod($perm & 07777, $fh); - print $fh PublicInbox::Git::read_all($oh); + print $fh PublicInbox::IO::read_all($oh); close $oh; # yes, this conflict checking is racy if multiple instances of this -- cgit v1.2.3-24-ge0c7