mirror of
https://github.com/glitch-soc/mastodon.git
synced 2026-03-29 03:00:33 +02:00
Fix OpenStack Swift Keystone token rate limiting (#38145)
This commit is contained in:
17
config/initializers/fog_connection_cache.rb
Normal file
17
config/initializers/fog_connection_cache.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
if ENV['SWIFT_ENABLED'] == 'true'
|
||||
module PaperclipFogConnectionCache
|
||||
def connection
|
||||
@connection ||= begin
|
||||
key = fog_credentials.hash
|
||||
Thread.current[:paperclip_fog_connections] ||= {}
|
||||
Thread.current[:paperclip_fog_connections][key] ||= ::Fog::Storage.new(fog_credentials)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Rails.application.config.after_initialize do
|
||||
Paperclip::Storage::Fog.prepend(PaperclipFogConnectionCache)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user