* For products that are directories (like manuals), allow a default
suffix other than index.html to be declared. E.g. if a build does echo "doc manual $out manual.html" >> $out/nix-support/hydra-build-products the default link for the product is http://localhost:3000/build/417/download/1/manual.html but other files are also accessible, e.g. http://localhost:3000/build/417/download/1/style.css
This commit is contained in:
@ -80,13 +80,17 @@ sub loadLog {
|
||||
|
||||
|
||||
sub download : Chained('build') PathPart('download') {
|
||||
my ($self, $c, $productnr, $filename, @path) = @_;
|
||||
my ($self, $c, $productnr, @path) = @_;
|
||||
|
||||
my $product = $c->stash->{build}->buildproducts->find({productnr => $productnr});
|
||||
notFound($c, "Build doesn't have a product $productnr.") if !defined $product;
|
||||
|
||||
notFound($c, "Product " . $product->path . " has disappeared.") unless -e $product->path;
|
||||
|
||||
# If the product has a name, then the first path element can be
|
||||
# ignored (it's the name included in the URL for informational purposes).
|
||||
shift @path if $product->name;
|
||||
|
||||
# Security paranoia.
|
||||
foreach my $elem (@path) {
|
||||
error($c, "Invalid filename $elem.") if $elem !~ /^$pathCompRE$/;
|
||||
@ -104,6 +108,8 @@ sub download : Chained('build') PathPart('download') {
|
||||
|
||||
notFound($c, "File $path does not exist.") if !-e $path;
|
||||
|
||||
notFound($c, "Path $path is a directory.") if -d $path;
|
||||
|
||||
$c->serve_static_file($path);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user