]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
lei blob: fix attachment extraction for unimported||inflight
authorEric Wong <e@80x24.org>
Thu, 11 Apr 2024 18:58:26 +0000 (18:58 +0000)
committerEric Wong <e@80x24.org>
Fri, 12 Apr 2024 02:59:48 +0000 (02:59 +0000)
Noticed while trying to make other reliability improvements to
lei...

lib/PublicInbox/LeiBlob.pm

index 127cc81ef5654cf2db8298c6ca5ffec75c18faa4..00697097bd4f1163c24968ff66bcdf17ed27ba6f 100644 (file)
@@ -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;