]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
lei blob: run cat_blob on lei/store for pending blobs
authorEric Wong <e@80x24.org>
Wed, 11 Oct 2023 07:20:56 +0000 (07:20 +0000)
committerEric Wong <e@80x24.org>
Wed, 11 Oct 2023 22:10:50 +0000 (22:10 +0000)
This can probably be made asynchronous in the future via
PublicInbox::InputPipe, but it's good enough for testing.

lib/PublicInbox/LeiBlob.pm
lib/PublicInbox/LeiStore.pm

index 8df83b1dfa520fe1bbd319771e49491f6bb468cd..d069d4a837e183ce17a689417715604339d1fcc9 100644 (file)
@@ -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> });
index e19ec88e721e92d41f4304a463f552918b620604..9c07af14eaebe95b45c9593f9a080fc1e8a39ad7 100644 (file)
@@ -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) = @_;