From 02cba7561022a2c1bc0ad73453e81fd84e772e20 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 21 Aug 2013 14:30:38 +0200 Subject: [PATCH] Add an action to download a specific output of a build as a .nar.bz2 E.g. http://hydra/build/3515983/output/out downloads the output named "out" as a bzip2-compressed NAR. --- src/lib/Hydra/Controller/Build.pm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/lib/Hydra/Controller/Build.pm b/src/lib/Hydra/Controller/Build.pm index 77532657..46fe1d5c 100644 --- a/src/lib/Hydra/Controller/Build.pm +++ b/src/lib/Hydra/Controller/Build.pm @@ -245,6 +245,21 @@ sub download : Chained('buildChain') PathPart { } +sub output : Chained('buildChain') PathPart Args(1) { + my ($self, $c, $outputName) = @_; + my $build = $c->stash->{build}; + + error($c, "This build is not finished yet.") unless $build->finished; + my $output = $build->buildoutputs->find({name => $outputName}); + notFound($c, "This build has no output named ‘$outputName’") unless defined $output; + error($c, "Output is not available.") unless isValidPath $output->path; + + $c->response->header('Content-Disposition', "attachment; filename=\"build-${\$build->id}-${\$outputName}.nar.bz2\""); + $c->stash->{current_view} = 'NixNAR'; + $c->stash->{storePath} = $output->path; +} + + # Redirect to a download with the given type. Useful when you want to # link to some build product of the latest build (i.e. in conjunction # with the .../latest redirect).