Skip to content

Commit 486c6e0

Browse files
committed
Use find_or_create when registering assets
This is to avoid a race condition where the asset was already registered. See: https://progress.opensuse.org/issues/188007
1 parent fad3731 commit 486c6e0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/OpenQA/Schema/ResultSet/Assets.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ sub register ($self, $type, $name, $options = {}) {
4242
$asset->refresh_size if $options->{refresh_size};
4343
if (my $created_by = $options->{created_by}) {
4444
my $scope = $options->{scope} // 'public';
45-
$created_by->jobs_assets->create({asset_id => $asset->id, created_by => 1});
45+
$created_by->jobs_assets->find_or_create({asset_id => $asset->id, created_by => 1});
4646
$created_by->reevaluate_children_asset_settings if $scope ne 'public';
4747
}
4848
return $asset;

0 commit comments

Comments
 (0)