Revert "Don't compress already-compressed files."

This reverts commit 190bffd846.
This commit is contained in:
Eelco Dolstra 2013-07-01 18:46:18 +02:00
parent 11414b0447
commit fe030331b5
2 changed files with 2 additions and 17 deletions

View file

@ -2,7 +2,6 @@ package Hydra::View::NARInfo;
use strict; use strict;
use base qw/Catalyst::View/; use base qw/Catalyst::View/;
use Hydra::View::NixNAR;
use File::Basename; use File::Basename;
use Nix::Store; use Nix::Store;
@ -18,7 +17,7 @@ sub process {
my $info; my $info;
$info .= "StorePath: $storePath\n"; $info .= "StorePath: $storePath\n";
$info .= "URL: nar/" . basename $storePath. "\n"; $info .= "URL: nar/" . basename $storePath. "\n";
$info .= "Compression: " . file_compression $storePath . "\n"; $info .= "Compression: bzip2\n";
$info .= "NarHash: $narHash\n"; $info .= "NarHash: $narHash\n";
$info .= "NarSize: $narSize\n"; $info .= "NarSize: $narSize\n";
$info .= "References: " . join(" ", map { basename $_ } @{$refs}) . "\n"; $info .= "References: " . join(" ", map { basename $_ } @{$refs}) . "\n";

View file

@ -3,30 +3,16 @@ package Hydra::View::NixNAR;
use strict; use strict;
use base qw/Catalyst::View/; use base qw/Catalyst::View/;
sub file_compression {
my ($file) = $@_;
if /\\.(gz|bz2|xz|lz|zip)/
return "none";
else
return "bzip2";
}
sub process { sub process {
my ($self, $c) = @_; my ($self, $c) = @_;
my $storePath = $c->stash->{storePath}; my $storePath = $c->stash->{storePath};
my $compression = file_compression($storePath);
$c->response->content_type('application/x-nix-archive'); # !!! check MIME type $c->response->content_type('application/x-nix-archive'); # !!! check MIME type
$c->response->content_length(-s $storePath) if ($compression == "none");
my $fh = new IO::Handle; my $fh = new IO::Handle;
if ($compression == "none") open $fh, "nix-store --dump '$storePath' | bzip2 |";
open $fh, "nix-store --dump '$storePath' |";
else
open $fh, "nix-store --dump '$storePath' | bzip2 |";
$c->response->body($fh); $c->response->body($fh);