RunCommandLogs: identify and access via uuid
Using a sha1 of the command combined with the build ID is not a particularly good or unique identifier: * A build could fail, be restarted, and then succeed -- assuming no configuration changes, the sha1 hash of the command as well as the build ID will be the same. This would lead to an overwritten log file. * Allowing user input to influence filenames is not the best of ideas.
This commit is contained in:
@ -175,8 +175,6 @@ __PACKAGE__->belongs_to(
|
||||
|
||||
use POSIX qw(WEXITSTATUS WIFEXITED WIFSIGNALED WTERMSIG);
|
||||
use UUID4::Tiny qw(create_uuid_string);
|
||||
use Digest::SHA1 qw(sha1_hex);
|
||||
use Hydra::Model::DB;
|
||||
|
||||
|
||||
=head2 new
|
||||
@ -366,29 +364,3 @@ sub did_fail_with_exec_error {
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
=head2 log_relative_url
|
||||
|
||||
Returns the URL to the log file relative to the build it belongs to.
|
||||
|
||||
Return:
|
||||
|
||||
* The relative URL if a log file exists
|
||||
* An empty string otherwise
|
||||
=cut
|
||||
sub log_relative_url() {
|
||||
my ($self) = @_;
|
||||
|
||||
# Do not return a URL when there is no build yet
|
||||
if (not defined($self->start_time)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
my $sha = sha1_hex($self->command);
|
||||
# Do not return a URL when there is no log file yet
|
||||
if (not -f Hydra::Model::DB::getHydraPath . "/runcommand-logs/" . substr($sha, 0, 2) . "/$sha-" . $self->build_id) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return "runcommand-log/$sha";
|
||||
}
|
||||
|
Reference in New Issue
Block a user