forked from lix-project/hydra
* Use IO::Handles instead of old school filehandles. This ensures
that the pipe gets closed, and the child process dies, if the HTTP connection is prematurely interrupted.
This commit is contained in:
parent
7ea69e7a9d
commit
8b752627a2
|
@ -11,10 +11,9 @@ sub process {
|
||||||
|
|
||||||
my @storePaths = @{$c->stash->{storePaths}};
|
my @storePaths = @{$c->stash->{storePaths}};
|
||||||
|
|
||||||
open(OUTPUT, "nix-store --export `nix-store -qR @storePaths` | gzip |");
|
|
||||||
|
|
||||||
my $fh = new IO::Handle;
|
my $fh = new IO::Handle;
|
||||||
$fh->fdopen(fileno(OUTPUT), "r") or die;
|
|
||||||
|
open $fh, "nix-store --export `nix-store -qR @storePaths` | gzip |";
|
||||||
|
|
||||||
$c->response->body($fh);
|
$c->response->body($fh);
|
||||||
|
|
||||||
|
|
|
@ -11,10 +11,9 @@ sub process {
|
||||||
|
|
||||||
my @storePaths = @{$c->stash->{storePaths}};
|
my @storePaths = @{$c->stash->{storePaths}};
|
||||||
|
|
||||||
open(OUTPUT, "nix-store --query --graph @storePaths | dot -Tpng -Gbgcolor=transparent |");
|
|
||||||
|
|
||||||
my $fh = new IO::Handle;
|
my $fh = new IO::Handle;
|
||||||
$fh->fdopen(fileno(OUTPUT), "r") or die;
|
|
||||||
|
open $fh, "nix-store --query --graph @storePaths | dot -Tpng -Gbgcolor=transparent |";
|
||||||
|
|
||||||
$c->response->body($fh);
|
$c->response->body($fh);
|
||||||
|
|
||||||
|
|
|
@ -10,15 +10,12 @@ sub process {
|
||||||
|
|
||||||
$c->response->content_type('application/x-nix-archive'); # !!! check MIME type
|
$c->response->content_type('application/x-nix-archive'); # !!! check MIME type
|
||||||
|
|
||||||
open(OUTPUT, "nix-store --dump '$storePath' | bzip2 |");
|
|
||||||
|
|
||||||
my $fh = new IO::Handle;
|
my $fh = new IO::Handle;
|
||||||
$fh->fdopen(fileno(OUTPUT), "r") or die;
|
|
||||||
|
open $fh, "nix-store --dump '$storePath' | bzip2 |";
|
||||||
|
|
||||||
$c->response->body($fh);
|
$c->response->body($fh);
|
||||||
|
|
||||||
undef $fh;
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue