hydra/src/lib/Hydra/View/NixNAR.pm
Eelco Dolstra 8b752627a2 * 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.
2009-03-11 14:44:34 +00:00

23 lines
387 B
Perl

package Hydra::View::NixNAR;
use strict;
use base qw/Catalyst::View/;
sub process {
my ($self, $c) = @_;
my $storePath = $c->stash->{storePath};
$c->response->content_type('application/x-nix-archive'); # !!! check MIME type
my $fh = new IO::Handle;
open $fh, "nix-store --dump '$storePath' | bzip2 |";
$c->response->body($fh);
return 1;
}
1;