forked from lix-project/hydra
Return 410 Gone (rather than 500) if an output is no longer available
This commit is contained in:
parent
6327edd63f
commit
66b8c1a9e0
|
@ -84,10 +84,8 @@ sub pkg : Chained('nix') PathPart Args(1) {
|
||||||
|| notFound($c, "No such package in this channel.");
|
|| notFound($c, "No such package in this channel.");
|
||||||
}
|
}
|
||||||
|
|
||||||
unless (all { isValidPath($_->path) } $c->stash->{build}->buildoutputs->all) {
|
gone($c, "Build " . $c->stash->{build}->id . " is no longer available.")
|
||||||
$c->response->status(410); # "Gone"
|
unless all { isValidPath($_->path) } $c->stash->{build}->buildoutputs->all;
|
||||||
error($c, "Build " . $c->stash->{build}->id . " is no longer available.");
|
|
||||||
}
|
|
||||||
|
|
||||||
$c->stash->{manifestUri} = $c->uri_for($self->action_for("manifest"), $c->req->captures);
|
$c->stash->{manifestUri} = $c->uri_for($self->action_for("manifest"), $c->req->captures);
|
||||||
|
|
||||||
|
|
|
@ -242,7 +242,7 @@ sub output : Chained('buildChain') PathPart Args(1) {
|
||||||
error($c, "This build is not finished yet.") unless $build->finished;
|
error($c, "This build is not finished yet.") unless $build->finished;
|
||||||
my $output = $build->buildoutputs->find({name => $outputName});
|
my $output = $build->buildoutputs->find({name => $outputName});
|
||||||
notFound($c, "This build has no output named ‘$outputName’") unless defined $output;
|
notFound($c, "This build has no output named ‘$outputName’") unless defined $output;
|
||||||
error($c, "Output is not available.") unless isValidPath $output->path;
|
gone($c, "Output is no longer available.") unless isValidPath $output->path;
|
||||||
|
|
||||||
$c->response->header('Content-Disposition', "attachment; filename=\"build-${\$build->id}-${\$outputName}.nar.bz2\"");
|
$c->response->header('Content-Disposition', "attachment; filename=\"build-${\$build->id}-${\$outputName}.nar.bz2\"");
|
||||||
$c->stash->{current_view} = 'NixNAR';
|
$c->stash->{current_view} = 'NixNAR';
|
||||||
|
|
|
@ -230,10 +230,7 @@ sub nar :Local :Args(1) {
|
||||||
|
|
||||||
$path = ($ENV{NIX_STORE_DIR} || "/nix/store")."/$path";
|
$path = ($ENV{NIX_STORE_DIR} || "/nix/store")."/$path";
|
||||||
|
|
||||||
if (!isValidPath($path)) {
|
gone($c, "Path " . $path . " is no longer available.") unless isValidPath($path);
|
||||||
$c->response->status(410); # "Gone"
|
|
||||||
error($c, "Path " . $path . " is no longer available.");
|
|
||||||
}
|
|
||||||
|
|
||||||
$c->stash->{current_view} = 'NixNAR';
|
$c->stash->{current_view} = 'NixNAR';
|
||||||
$c->stash->{storePath} = $path;
|
$c->stash->{storePath} = $path;
|
||||||
|
|
|
@ -15,7 +15,7 @@ use feature qw/switch/;
|
||||||
our @ISA = qw(Exporter);
|
our @ISA = qw(Exporter);
|
||||||
our @EXPORT = qw(
|
our @EXPORT = qw(
|
||||||
getBuild getPreviousBuild getNextBuild getPreviousSuccessfulBuild
|
getBuild getPreviousBuild getNextBuild getPreviousSuccessfulBuild
|
||||||
error notFound accessDenied
|
error notFound gone accessDenied
|
||||||
forceLogin requireUser requireProjectOwner requireAdmin requirePost isAdmin isProjectOwner
|
forceLogin requireUser requireProjectOwner requireAdmin requirePost isAdmin isProjectOwner
|
||||||
trim
|
trim
|
||||||
getLatestFinishedEval
|
getLatestFinishedEval
|
||||||
|
@ -103,6 +103,12 @@ sub notFound {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub gone {
|
||||||
|
my ($c, $msg) = @_;
|
||||||
|
error($c, $msg, 410);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
sub accessDenied {
|
sub accessDenied {
|
||||||
my ($c, $msg) = @_;
|
my ($c, $msg) = @_;
|
||||||
error($c, $msg, 403);
|
error($c, $msg, 403);
|
||||||
|
|
Loading…
Reference in a new issue