unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
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	[thread overview]
Message-ID: <20231011072057.758022-9-e@80x24.org> (raw)
In-Reply-To: <20231011072057.758022-1-e@80x24.org>

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) = @_;

  parent reply	other threads:[~2023-10-11  7:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-11  7:20 [PATCH 0/9] lei + import-related updates Eric Wong
2023-10-11  7:20 ` [PATCH 1/9] lei rediff: use ProcessIO for --drq support Eric Wong
2023-10-11  7:20 ` [PATCH 2/9] lei_xsearch: improve curl progress reporting Eric Wong
2023-10-11  7:20 ` [PATCH 3/9] msgtime: quiet warnings we can do nothing about Eric Wong
2023-10-11  7:20 ` [PATCH 4/9] msgtime: simplify msg_timestamp and msg_datestamp Eric Wong
2023-10-11  7:20 ` [PATCH 5/9] treewide: consolidate "From " line removal Eric Wong
2023-10-11  7:20 ` [PATCH 6/9] import: switch to Unix stream socket for fast-import Eric Wong
2023-10-11  7:20 ` [PATCH 7/9] import: cat_blob is a no-op w/o live fast-import Eric Wong
2023-10-11  7:20 ` Eric Wong [this message]
2023-10-11  7:20 ` [PATCH 9/9] lei import|tag|rm: support --commit-delay=SECONDS Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231011072057.758022-9-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).