]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/ViewVCS.pm
view: display redundant headers in permalink
[public-inbox.git] / lib / PublicInbox / ViewVCS.pm
index b41adc44b4418abedca31e93d1cfa9b2e6b73ef5..369afe93bd2a528a9155a2f7ce0a2d43097dd5fb 100644 (file)
@@ -20,6 +20,7 @@ use bytes (); # only for bytes::length
 use PublicInbox::SolverGit;
 use PublicInbox::WwwStream;
 use PublicInbox::Linkify;
+use PublicInbox::Tmpfile;
 use PublicInbox::Hval qw(ascii_html to_filename);
 my $hl = eval {
        require PublicInbox::HlMod;
@@ -48,6 +49,7 @@ sub stream_large_blob ($$$$) {
        my $qsp = PublicInbox::Qspawn->new($cmd);
        my @cl = ('Content-Length', $size);
        my $env = $ctx->{env};
+       $env->{'public-inbox.tmpgit'} = $git; # for {-tmp}/File::Temp::Dir
        $env->{'qspawn.wcb'} = delete $ctx->{-wcb};
        $qsp->psgi_return($env, undef, sub {
                my ($r, $bref) = @_;
@@ -135,14 +137,14 @@ sub solve_result {
                return html_page($ctx, 500, \$log);
        }
 
-       my $binary = index($$blob, "\0") >= 0;
+       my $bin = index(substr($$blob, 0, $BIN_DETECT), "\0") >= 0;
        if (defined $fn) {
                my $h = [ 'Content-Length', $size, 'Content-Type' ];
-               push(@$h, ($binary ? 'application/octet-stream' : 'text/plain'));
+               push(@$h, ($bin ? 'application/octet-stream' : 'text/plain'));
                return delete($ctx->{-wcb})->([200, $h, [ $$blob ]]);
        }
 
-       if ($binary) {
+       if ($bin) {
                $log = "<pre>$oid $type $size bytes (binary)" .
                        " $raw_link</pre>" . $log;
                return html_page($ctx, 200, \$log);
@@ -184,7 +186,7 @@ sub show ($$;$) {
                $hints->{$to} = $v;
        }
 
-       open my $log, '+>', undef or die "open: $!";
+       my $log = tmpfile("solve.$oid_b");
        my $solver = PublicInbox::SolverGit->new($ctx->{-inbox}, sub {
                solve_result($ctx, $_[0], $log, $hints, $fn);
        });