forked from lix-project/hydra
Helper/Nix: constructRunCommandLogPath: return undef in case of an error
This allows us to give a web request to an invalid UUID a 404.
This commit is contained in:
parent
2c6487b8d7
commit
e381751564
|
@ -538,7 +538,7 @@ sub runcommandlog :Local :Args(1) {
|
|||
die if defined $tail && $tail !~ /^[0-9]+$/;
|
||||
|
||||
my $runlog = $c->model('DB')->resultset('RunCommandLogs')->find({ uuid => $uuid });
|
||||
my $logFile = constructRunCommandLogPath($runlog);
|
||||
my $logFile = constructRunCommandLogPath($runlog) or notFound($c, "RunCommandLog not found.");
|
||||
if (-f $logFile) {
|
||||
serveLogFile($c, $logFile, $tail);
|
||||
return;
|
||||
|
|
|
@ -592,12 +592,17 @@ sub isLocalStore {
|
|||
|
||||
sub constructRunCommandLogPath {
|
||||
my ($runlog) = @_;
|
||||
my $path = undef;
|
||||
|
||||
eval {
|
||||
my $uuid = $runlog->uuid;
|
||||
my $hydra_path = Hydra::Model::DB::getHydraPath;
|
||||
my $bucket = substr($uuid, 0, 2);
|
||||
|
||||
return "$hydra_path/runcommand-logs/$bucket/$uuid";
|
||||
$path = "$hydra_path/runcommand-logs/$bucket/$uuid";
|
||||
};
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -163,7 +163,7 @@ sub buildFinished {
|
|||
|
||||
$runlog->started();
|
||||
|
||||
my $logPath = Hydra::Helper::Nix::constructRunCommandLogPath($runlog);
|
||||
my $logPath = Hydra::Helper::Nix::constructRunCommandLogPath($runlog) or die "RunCommandLog not found.";
|
||||
my $dir = dirname($logPath);
|
||||
my $oldUmask = umask();
|
||||
|
||||
|
|
Loading…
Reference in a new issue