about summary refs log tree commit homepage
path: root/lib/PublicInbox/RepoGitSrc.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2017-03-04 03:52:29 +0000
committerEric Wong <e@80x24.org>2017-03-04 03:52:29 +0000
commit8a3fc4a2f027b36f27225ceee5908c571c8f4f47 (patch)
tree5ab6f45dc41d3d25bf71bcdd5c9c3108a22a8fbd /lib/PublicInbox/RepoGitSrc.pm
parentd78b17adabb1880857c67fda40be0c47fe9d1866 (diff)
downloadpublic-inbox-8a3fc4a2f027b36f27225ceee5908c571c8f4f47.tar.gz
We need to ensure we've fully-drained the pipe before
signalling EOF to the callback, since pipelining may
not be the best choice with detachable processes
in the future.
Diffstat (limited to 'lib/PublicInbox/RepoGitSrc.pm')
-rw-r--r--lib/PublicInbox/RepoGitSrc.pm21
1 files changed, 10 insertions, 11 deletions
diff --git a/lib/PublicInbox/RepoGitSrc.pm b/lib/PublicInbox/RepoGitSrc.pm
index 67de86ee..51048773 100644
--- a/lib/PublicInbox/RepoGitSrc.pm
+++ b/lib/PublicInbox/RepoGitSrc.pm
@@ -154,18 +154,17 @@ sub git_blob_show {
                 return if $ref eq 'ARRAY'; # redundant info
                 if ($ref eq 'SCALAR') {
                         $buf .= $$r;
-                        if (bytes::length($buf) == $size) {
-                                my $fh = $res->($self->rt(200, 'html'));
-                                my $sed = git_blob_sed($req, $hex, $size);
-                                $fh->write($sed->($buf));
-                                $fh->write($sed->(undef));
-                                $fh->close;
-                        }
-                        return;
+                } elsif (!defined $r) {
+                        my $cb = $res or return;
+                        $res = undef;
+                        $cb->($self->rt(500, 'plain', "Error\n"));
+                } elsif ($r == 0) {
+                        my $fh = $res->($self->rt(200, 'html'));
+                        my $sed = git_blob_sed($req, $hex, $size);
+                        $fh->write($sed->($buf));
+                        $fh->write($sed->(undef));
+                        $fh->close;
                 }
-                my $cb = $res or return;
-                $res = undef;
-                $cb->($self->rt(500, 'plain', "Error\n"));
         });
 }