mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-10 21:26:07 +10:00
If a DB migration occurs, there's a chance that the application settings are loaded from the cache and provide stale values, causing Error 500s. This ensures that at startup the settings are always refreshed. Closes #3643
42 lines
845 B
Ruby
42 lines
845 B
Ruby
# == Schema Information
|
|
#
|
|
# Table name: ci_application_settings
|
|
#
|
|
# id :integer not null, primary key
|
|
# all_broken_builds :boolean
|
|
# add_pusher :boolean
|
|
# created_at :datetime
|
|
# updated_at :datetime
|
|
#
|
|
|
|
module Ci
|
|
class ApplicationSetting < ActiveRecord::Base
|
|
extend Ci::Model
|
|
|
|
after_commit do
|
|
Rails.cache.write(cache_key, self)
|
|
end
|
|
|
|
def self.expire
|
|
Rails.cache.delete(cache_key)
|
|
end
|
|
|
|
def self.current
|
|
Rails.cache.fetch(cache_key) do
|
|
Ci::ApplicationSetting.last
|
|
end
|
|
end
|
|
|
|
def self.create_from_defaults
|
|
create(
|
|
all_broken_builds: Settings.gitlab_ci['all_broken_builds'],
|
|
add_pusher: Settings.gitlab_ci['add_pusher'],
|
|
)
|
|
end
|
|
|
|
def self.cache_key
|
|
'ci_application_setting.last'
|
|
end
|
|
end
|
|
end
|