From f9c0996003fb4942ee322731f841ca5df6e91aaf Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 12 Nov 2008 14:41:51 +0000 Subject: [PATCH] * Allow downloading of build products. --- .../lib/HydraFrontend/Controller/Root.pm | 15 +++++++++++++++ src/HydraFrontend/root/build.tt | 18 ++++++++++-------- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/HydraFrontend/lib/HydraFrontend/Controller/Root.pm b/src/HydraFrontend/lib/HydraFrontend/Controller/Root.pm index 8fac493e..c7608337 100644 --- a/src/HydraFrontend/lib/HydraFrontend/Controller/Root.pm +++ b/src/HydraFrontend/lib/HydraFrontend/Controller/Root.pm @@ -162,6 +162,21 @@ sub loadLog { } +sub download :Local { + my ( $self, $c, $id, $productnr, $filename ) = @_; + + my $build = getBuild($c, $id); + return error($c, "Build with ID $id doesn't exist.") if !defined $build; + + my $product = $build->buildproducts->find({productnr => $productnr}); + return error($c, "Build $id doesn't have a product $productnr.") if !defined $product; + + return error($c, "File " . $product->path . " has disappeared.") unless -e $product->path; + + $c->serve_static_file($product->path); +} + + sub end : ActionClass('RenderView') {} diff --git a/src/HydraFrontend/root/build.tt b/src/HydraFrontend/root/build.tt index a859ef97..672c01fc 100644 --- a/src/HydraFrontend/root/build.tt +++ b/src/HydraFrontend/root/build.tt @@ -197,14 +197,16 @@ [% CASE "nix-build" %] Nix build of path [% product.path %] [% CASE "file" %] - [% SWITCH product.subtype %] - [% CASE "source-dist" %] - Source Source distribution [% product.name %] - [% CASE "rpm" %] - RPM RPM package [% product.name %] - [% CASE DEFAULT %] - File [% product.path %] of type [% product.subtype %] - [% END %] + + [% SWITCH product.subtype %] + [% CASE "source-dist" %] + Source Source distribution [% product.name %] + [% CASE "rpm" %] + RPM RPM package [% product.name %] + [% CASE DEFAULT %] + File [% product.name %] of type [% product.subtype %] + [% END %] + [details]