From: Eric Wong Date: Wed, 11 Oct 2023 07:20:56 +0000 (+0000) Subject: lei blob: run cat_blob on lei/store for pending blobs X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=905f07417459f958b394cad1c4ccd86f6f8cce7c;p=thirdparty%2Fpublic-inbox.git lei blob: run cat_blob on lei/store for pending blobs This can probably be made asynchronous in the future via PublicInbox::InputPipe, but it's good enough for testing. --- diff --git a/lib/PublicInbox/LeiBlob.pm b/lib/PublicInbox/LeiBlob.pm index 8df83b1df..d069d4a83 100644 --- a/lib/PublicInbox/LeiBlob.pm +++ b/lib/PublicInbox/LeiBlob.pm @@ -9,6 +9,7 @@ use v5.10.1; use parent qw(PublicInbox::IPC); use PublicInbox::Spawn qw(run_wait popen_rd which); use PublicInbox::DS; +use PublicInbox::Eml; sub get_git_dir ($$) { my ($lei, $d) = @_; @@ -121,18 +122,21 @@ sub lei_blob { 'cat-file', 'blob', $blob ]; if (defined $lei->{-attach_idx}) { my $fh = popen_rd($cmd, $lei->{env}, $rdr); - require PublicInbox::Eml; my $buf = do { local $/; <$fh> }; return extract_attach($lei, $blob, \$buf) if close($fh); } $rdr->{1} = $lei->{1}; my $cerr = run_wait($cmd, $lei->{env}, $rdr) or return; my $lms = $lei->lms; - if (my $bref = $lms ? $lms->local_blob($blob, 1) : undef) { - defined($lei->{-attach_idx}) and - return extract_attach($lei, $blob, $bref); - return $lei->out($$bref); - } elsif ($opt->{mail}) { + my $bref = ($lms ? $lms->local_blob($blob, 1) : undef) // do { + my $sto = $lei->{sto} // $lei->_lei_store; + $sto && $sto->{-wq_s1} ? $sto->wq_do('cat_blob', $blob) + : undef; + }; + $bref and return $lei->{-attach_idx} ? + extract_attach($lei, $blob, $bref) : + $lei->out($$bref); + if ($opt->{mail}) { my $eh = $rdr->{2}; seek($eh, 0, 0); return $lei->child_error($cerr, do { local $/; <$eh> }); diff --git a/lib/PublicInbox/LeiStore.pm b/lib/PublicInbox/LeiStore.pm index e19ec88e7..9c07af14e 100644 --- a/lib/PublicInbox/LeiStore.pm +++ b/lib/PublicInbox/LeiStore.pm @@ -108,6 +108,11 @@ sub search { PublicInbox::LeiSearch->new($_[0]->{priv_eidx}->{topdir}); } +sub cat_blob { + my ($self, $oid) = @_; + $self->{im} ? $self->{im}->cat_blob($oid) : undef; +} + # follows the stderr file sub _tail_err { my ($self) = @_;