From 23416f996062ab45db4890f624e7e770b77881c4 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 24 Apr 2014 10:52:46 +0200 Subject: [PATCH] Do a permanent redirect --- src/lib/Hydra/Controller/Jobset.pm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lib/Hydra/Controller/Jobset.pm b/src/lib/Hydra/Controller/Jobset.pm index 3fc5e26f..113279b4 100644 --- a/src/lib/Hydra/Controller/Jobset.pm +++ b/src/lib/Hydra/Controller/Jobset.pm @@ -10,7 +10,6 @@ use Hydra::Helper::CatalystUtils; sub jobsetChain :Chained('/') :PathPart('jobset') :CaptureArgs(2) { my ($self, $c, $projectName, $jobsetName) = @_; - $c->stash->{params}->{name} //= $jobsetName; my $project = $c->model('DB::Projects')->find($projectName); @@ -23,8 +22,15 @@ sub jobsetChain :Chained('/') :PathPart('jobset') :CaptureArgs(2) { if (!$c->stash->{jobset} && !($c->action->name eq "jobset" and $c->request->method eq "PUT")) { my $rename = $project->jobsetrenames->find({ from_ => $jobsetName }); notFound($c, "Jobset ‘$jobsetName’ doesn't exist.") unless defined $rename; - $c->stash->{jobset} = $project->jobsets->find({ name => $rename->to_ }) or die; + + # Return a permanent redirect to the new jobset name. + my @captures = @{$c->req->captures}; + $captures[1] = $rename->to_; + $c->res->redirect($c->uri_for($c->action, \@captures, $c->req->params), 301); + $c->detach; } + + $c->stash->{params}->{name} //= $jobsetName; }