implement git-upload-pack
|
1 |
<% |
2 |
use IPC::Open3 (); |
|
3 |
use Symbol (); |
|
4 |
use IO::Select (); |
|
5 |
|
|
6 |
my $service = param('service'); |
|
7 |
my $user = param('user'); |
|
8 |
my $project = param('project'); |
|
9 |
|
|
revert encoding support
|
10 |
my $git = app->git; |
implement git-upload-pack
|
11 |
|
cleanup
|
12 |
my $rep_info = app->rep_info($user, $project); |
13 |
my $rep_git_dir = $rep_info->{git_dir}; |
|
remove cmd_rep
|
14 |
my @cmd = $git->cmd(app->rep_info($user, $project), $service, '--stateless-rpc', $rep_git_dir); |
implement git-upload-pack
|
15 |
|
add FAQ large repository can...
|
16 |
# Command |
implement git-upload-pack
|
17 |
my ($cout, $cerr) = (Symbol::gensym, Symbol::gensym); |
18 |
my $pid = IPC::Open3::open3(my $cin, $cout, $cerr, @cmd); |
|
improve memory usage of smar...
|
19 |
my $pos = 0; |
add FAQ large repository can...
|
20 |
my $content = $self->req->content; |
improve memory usage of smar...
|
21 |
while (1) { |
22 |
my $chunk = $content->get_body_chunk($pos); |
|
23 |
last unless defined $chunk; |
|
24 |
my $length = length $chunk; |
|
25 |
last unless $length; |
|
26 | ||
27 |
print $cin $chunk; |
|
28 |
$pos += $length; |
|
29 |
} |
|
implement git-upload-pack
|
30 |
close $cin; |
31 |
|
|
32 |
# Response |
|
33 |
$self->res->headers->content_type("application/x-git-$service-result"); |
|
34 |
$self->render_later; |
|
35 |
|
|
36 |
# Write |
|
37 |
my $s = IO::Select->new($cout, $cerr); |
|
cleanup
|
38 |
my $buffer_size = $ENV{GITPREP_SMART_HTTP_BUFFER_SIZE}; |
fix bug that lerge repositor...
|
39 |
my $error; |
40 |
my @ready; |
|
fix defunct process remainin...
|
41 |
my $cb; |
implement git-upload-pack
|
42 |
$cb = sub { |
43 |
my $c = shift; |
|
fix bug that lerge repositor...
|
44 |
if (@ready = $s->can_read) { |
fix smart_http bug
|
45 |
my $output = ''; |
implement git-upload-pack
|
46 |
for my $handle (@ready) { |
fix bug that lerge repositor...
|
47 |
|
48 |
if (sysread($handle, my $buf, $buffer_size)) { |
|
implement git-upload-pack
|
49 |
if ($handle == $cerr) { |
Revert "fix smart http bug"
|
50 |
$error .= $buf; |
implement git-upload-pack
|
51 |
} |
52 |
else { |
|
Revert "fix smart http bug"
|
53 |
$output .= $buf; |
implement git-upload-pack
|
54 |
} |
55 |
} |
|
fix defunct process remainin...
|
56 |
else { |
57 |
$s->remove($handle); |
|
58 |
} |
|
implement git-upload-pack
|
59 |
} |
Revert "fix smart http bug"
|
60 |
$c->write_chunk($output, $cb); |
implement git-upload-pack
|
61 |
} |
62 |
else { |
|
fix bug that lerge repositor...
|
63 |
$c->finish; |
implement git-upload-pack
|
64 |
waitpid($pid, 0); |
fix smart-http not working b...
|
65 | |
66 |
$c->app->log->error($c->url_for . ": $error") if defined $error; |
|
implement git-upload-pack
|
67 |
undef $cb; |
68 |
return; |
|
69 |
} |
|
70 |
}; |
|
71 |
$self->$cb; |
|
72 |
%> |