]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/IMAP.pm
imap: introduce and use Git->async_prefetch
[public-inbox.git] / lib / PublicInbox / IMAP.pm
index 8ab4b1e7dba9e86853e7d93af5bc6c7627f0221e..3d66f9306ffc37c8e2664f2fb8f3acfc8c4933e4 100644 (file)
@@ -626,8 +626,13 @@ sub fetch_blob_cb { # called by git->cat_async via git_async_cat
        } else {
                $smsg->{blob} eq $oid or die "BUG: $smsg->{blob} != $oid";
        }
+       my $pre;
+       if (!$self->{wbuf} && (my $nxt = $msgs->[0])) {
+               $pre = $self->{ibx}->git->async_prefetch($nxt->{blob},
+                                               \&fetch_blob_cb, $fetch_arg);
+       }
        fetch_run_ops($self, $smsg, $bref, $ops, $partial);
-       requeue_once($self);
+       $pre ? $self->zflush : requeue_once($self);
 }
 
 sub emit_rfc822 {