user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* [PATCH] lei blob: fix attachment extraction for unimported||inflight
@ 2024-04-11 18:58 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2024-04-11 18:58 UTC (permalink / raw)
  To: meta

Noticed while trying to make other reliability improvements to
lei...
---
 lib/PublicInbox/LeiBlob.pm | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/lib/PublicInbox/LeiBlob.pm b/lib/PublicInbox/LeiBlob.pm
index 127cc81e..00697097 100644
--- a/lib/PublicInbox/LeiBlob.pm
+++ b/lib/PublicInbox/LeiBlob.pm
@@ -119,14 +119,17 @@ sub lei_blob {
 		} else {
 			open $rdr->{2}, '>', '/dev/null' or die "open: $!";
 		}
-		my $cmd = [ 'git', '--git-dir='.$lei->ale->git->{git_dir},
-				'cat-file', 'blob', $blob ];
+		my $cmd = $lei->ale->git->cmd('cat-file', 'blob', $blob);
+		my $cerr;
 		if (defined $lei->{-attach_idx}) {
 			my $buf = run_qx($cmd, $lei->{env}, $rdr);
 			return extract_attach($lei, $blob, \$buf) unless $?;
+			$cerr = $?;
+		} else {
+			$rdr->{1} = $lei->{1}; # write directly to client
+			$cerr = run_wait($cmd, $lei->{env}, $rdr) or return;
 		}
-		$rdr->{1} = $lei->{1};
-		my $cerr = run_wait($cmd, $lei->{env}, $rdr) or return;
+		# fall back to unimported ('lei index') and inflight blobs
 		my $lms = $lei->lms;
 		my $bref = ($lms ? $lms->local_blob($blob, 1) : undef) // do {
 			my $sto = $lei->{sto} // $lei->_lei_store;

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2024-04-11 18:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-11 18:58 [PATCH] lei blob: fix attachment extraction for unimported||inflight Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

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).