mirror of
https://github.com/mastodon/mastodon.git
synced 2026-03-14 22:44:08 +00:00
18 lines
485 B
Ruby
18 lines
485 B
Ruby
# 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
|