This can probably be made asynchronous in the future via
PublicInbox::InputPipe, but it's good enough for testing.
---
lib/PublicInbox/LeiBlob.pm | 16 ++++++++++------
lib/PublicInbox/LeiStore.pm | 5 +++++
2 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/lib/PublicInbox/LeiBlob.pm b/lib/PublicInbox/LeiBlob.pm
index 8df83b1d..d069d4a8 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 e19ec88e..9c07af14 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) = @_;