diff options
author | Eric Wong <e@80x24.org> | 2022-08-29 09:26:31 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2022-08-29 19:05:43 +0000 |
commit | b277b89cf3d5e7ad67257be13356c7f97ee805da (patch) | |
tree | 0d59a05855d1d93364bd799e068e0f2fb0df8a84 /lib/PublicInbox/ViewVCS.pm | |
parent | 1a8bb5fb6263cb2a709687267ecc684862ce7768 (diff) | |
download | public-inbox-b277b89cf3d5e7ad67257be13356c7f97ee805da.tar.gz |
This allows reusing inodes for /$COMMIT_OID/s/ requests. We'll also replace `log' with `lh' in the field name to avoid confusion with the `log' perlop.
Diffstat (limited to 'lib/PublicInbox/ViewVCS.pm')
-rw-r--r-- | lib/PublicInbox/ViewVCS.pm | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/PublicInbox/ViewVCS.pm b/lib/PublicInbox/ViewVCS.pm index 9bf010c2..c5d16478 100644 --- a/lib/PublicInbox/ViewVCS.pm +++ b/lib/PublicInbox/ViewVCS.pm @@ -231,12 +231,10 @@ sub show_commit ($$$$) { 'git show --encoding=UTF-8 --pretty=format:%n -M'. " --stat -p $oid >p && ". "git patch-id --stable <p" ]; - my $xenv = { GIT_DIR => $git->{git_dir} }; - my $tmp = File::Temp->newdir("show-$oid-XXXX", TMPDIR => 1); - my $qsp = PublicInbox::Qspawn->new($cmd, $xenv, { -C => "$tmp" }); + my $e = { GIT_DIR => $git->{git_dir} }; + my $qsp = PublicInbox::Qspawn->new($cmd, $e, { -C => "$ctx->{-tmp}" }); $qsp->{qsp_err} = \($ctx->{-qsp_err} = ''); $ctx->{-logref} = $logref; - $ctx->{-tmp} = $tmp; $ctx->{env}->{'qspawn.wcb'} = delete $ctx->{-wcb}; $ctx->{git} = $git; $qsp->psgi_qx($ctx->{env}, undef, \&show_commit_start, $ctx); @@ -260,7 +258,7 @@ sub show_other ($$$$) { # user_cb for SolverGit, called as: user_cb->($result_or_error, $uarg) sub solve_result { my ($res, $ctx) = @_; - my ($log, $hints, $fn) = delete @$ctx{qw(log hints fn)}; + my ($log, $hints, $fn) = delete @$ctx{qw(lh hints fn)}; unless (seek($log, 0, 0)) { warn "seek(log): $!"; @@ -345,15 +343,16 @@ sub show ($$;$) { defined(my $v = $qp->{$from}) or next; $hints->{$to} = $v if $v ne ''; } - - $ctx->{'log'} = tmpfile("solve.$oid_b") // die "tmpfile: $!"; $ctx->{fn} = $fn; + $ctx->{-tmp} = File::Temp->newdir("solver.$oid_b-XXXX", TMPDIR => 1); + open $ctx->{lh}, '+>>', "$ctx->{-tmp}/solve.log" or die "open: $!"; my $solver = PublicInbox::SolverGit->new($ctx->{ibx}, \&solve_result, $ctx); + $solver->{tmp} = $ctx->{-tmp}; # share tmpdir # PSGI server will call this immediately and give us a callback (-wcb) sub { $ctx->{-wcb} = $_[0]; # HTTP write callback - $solver->solve($ctx->{env}, $ctx->{log}, $oid_b, $hints); + $solver->solve($ctx->{env}, $ctx->{lh}, $oid_b, $hints); }; } |