diff options
author | Rémy Coutable <remy@rymai.me> | 2019-03-18 16:32:26 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2019-04-04 12:06:11 +0300 |
commit | f37f28b962376843e7682dad15067edb131ecdd8 (patch) | |
tree | 9ffc89724cfc6d03123c152ea2b0c7f60d7ec72c /app | |
parent | a6e9175fdd7790cc433ba49a85eaadbf75a3c8e9 (diff) |
Fix race cond. in ApplicationSettingImplementation.create_from_defaults
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'app')
-rw-r--r-- | app/models/application_setting.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index 9e91e4ab4b9..7ec8505b33a 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -223,4 +223,11 @@ class ApplicationSetting < ApplicationRecord reset_memoized_terms end after_commit :expire_performance_bar_allowed_user_ids_cache, if: -> { previous_changes.key?('performance_bar_allowed_group_id') } + + def self.create_from_defaults + super + rescue ActiveRecord::RecordNotUnique + # We already have an ApplicationSetting record, so just return it. + current_without_cache + end end |