]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
repobrowse: reduce checks for response fh
authorEric Wong <e@80x24.org>
Wed, 6 Apr 2016 03:14:40 +0000 (03:14 +0000)
committerEric Wong <e@80x24.org>
Wed, 6 Apr 2016 03:14:40 +0000 (03:14 +0000)
We should die horribly if fh is missing in some cases
due to a fatal bug, do not bug from us and risk losing
output data.

lib/PublicInbox/RepobrowseGitDiff.pm
lib/PublicInbox/RepobrowseGitPatch.pm
lib/PublicInbox/RepobrowseGitSnapshot.pm

index fb44c7526f9d55260068c7057e277089e6f17d97..02a2c562116e9c063be41f4ec41b956259c9a470 100644 (file)
@@ -78,9 +78,7 @@ sub call_git_diff {
                                        utf8_html("git diff-tree -r -M -B -D ".
                                                "$id2 $id --$ex"). "\n\n");
                }
-               if (my $fh = $req->{fh}) {
-                       git_diff_to_html($req, $fh);
-               }
+               git_diff_to_html($req);
        };
        if (my $async = $env->{'pi-httpd.async'}) {
                $req->{rpipe} = $async->($req->{rpipe}, $cb);
@@ -112,7 +110,8 @@ sub git_diff_line_i {
 }
 
 sub git_diff_to_html {
-       my ($req, $fh) = @_;
+       my ($req) = @_;
+       my $fh = $req->{fh};
        if (!$req->{diff_state}) {
                my ($stat, $buf) = split(/\0\0/, $req->{dbuf}, 2);
                return unless defined $buf;
index a6c5aad8970972527cd454c91951734d796f73c6..b8a44e512c135840dab15b7a4e135dd6e6578fe1 100644 (file)
@@ -61,7 +61,7 @@ sub call_git_patch {
                        $fh = $res->([200, $h]);
                        $res = undef;
                }
-               $fh->write($buf) if $fh;
+               $fh->write($buf);
        };
 
        if (my $async = $env->{'pi-httpd.async'}) {
index 106d5651e6f467bb2d324d408111a090dc01fd02..8bd4b0a57cf319e171d1bdc6cc44d8b4c59de274 100644 (file)
@@ -112,8 +112,7 @@ sub call_git_snapshot ($$) { # invoked by PublicInbox::RepobrowseBase::call
                                'ETag', qq("$tree") ];
                        $req->{fh} = $res->([200, $h]);
                }
-               my $fh = $req->{fh} or return;
-               $fh->write($buf);
+               $req->{fh}->write($buf);
        };
        if (my $async = $env->{'pi-httpd.async'}) {
                $req->{rpipe} = $async->($req->{rpipe}, $cb);