From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id A90B31F4B4 for ; Wed, 11 Oct 2023 07:20:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1697008858; bh=yoArJ5tFz57u7ZvEWKhJvzUOsTcBQ0jwDckNZ0x5H4U=; h=From:To:Subject:Date:In-Reply-To:References:From; b=EFH7qBqCQFO+vEo6YMh2QrF5NCl8YOIRrsdq0W+3NNJlm2+yJJ7mW0OoFN4VzLtO3 WTdCinvPSnbeCVk+Z+jKmP2FP0TH6Gyk/v7NtoJKWCV3/PgehCjhLpMXfhkL3GiOHh yxUMywnBL+kvwM95nifvXOSrrTu7m9S9U5HtnweI= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 8/9] lei blob: run cat_blob on lei/store for pending blobs Date: Wed, 11 Oct 2023 07:20:56 +0000 Message-ID: <20231011072057.758022-9-e@80x24.org> In-Reply-To: <20231011072057.758022-1-e@80x24.org> References: <20231011072057.758022-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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) = @_;