From ed1668704eeed28eee85791f6e0054317cc4f216 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 25 Feb 2009 14:50:17 +0000 Subject: [PATCH] --- src/Hydra/lib/Hydra/Base/Controller/Nix.pm | 15 +++++++++++++++ src/Hydra/lib/Hydra/Controller/Root.pm | 12 ------------ src/Hydra/lib/Hydra/View/NixManifest.pm | 2 +- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/Hydra/lib/Hydra/Base/Controller/Nix.pm b/src/Hydra/lib/Hydra/Base/Controller/Nix.pm index 9355f1cc..4e7fd35f 100644 --- a/src/Hydra/lib/Hydra/Base/Controller/Nix.pm +++ b/src/Hydra/lib/Hydra/Base/Controller/Nix.pm @@ -21,6 +21,21 @@ sub closure : Chained('nix') PathPart { sub manifest : Chained('nix') PathPart Args(0) { my ($self, $c) = @_; $c->stash->{current_view} = 'Hydra::View::NixManifest'; + $c->stash->{narBase} = $c->uri_for($self->action_for("nar"), $c->req->captures); +} + + +sub nar : Chained('nix') PathPart { + my ($self, $c, @rest) = @_; + + my $path .= "/" . join("/", @rest); + + error($c, "Path " . $path . " is no longer available.") unless isValidPath($path); + + # !!! check that $path is in the closure of $c->stash->{storePaths}. + + $c->stash->{current_view} = 'Hydra::View::NixNAR'; + $c->stash->{storePath} = $path; } diff --git a/src/Hydra/lib/Hydra/Controller/Root.pm b/src/Hydra/lib/Hydra/Controller/Root.pm index f46c4a17..f8fea216 100644 --- a/src/Hydra/lib/Hydra/Controller/Root.pm +++ b/src/Hydra/lib/Hydra/Controller/Root.pm @@ -562,18 +562,6 @@ sub nixpkg :Local { } -sub nar :Local { - my ($self, $c, @rest) = @_; - - my $path .= "/" . join("/", @rest); - - error($c, "Path " . $path . " is no longer available.") unless isValidPath($path); - - $c->stash->{current_view} = 'Hydra::View::NixNAR'; - $c->stash->{storePath} = $path; -} - - sub end : ActionClass('RenderView') { my ($self, $c) = @_; diff --git a/src/Hydra/lib/Hydra/View/NixManifest.pm b/src/Hydra/lib/Hydra/View/NixManifest.pm index cb45c197..54ce673f 100644 --- a/src/Hydra/lib/Hydra/View/NixManifest.pm +++ b/src/Hydra/lib/Hydra/View/NixManifest.pm @@ -37,7 +37,7 @@ sub process { or die "cannot query hash of `$path': $?"; chomp $hash; - my $url = $c->uri_for('/nar' . $path); + my $url = $c->stash->{narBase} . $path; my $deriver = `nix-store --query --deriver $path` or die "cannot query deriver of `$path': $?";