diff --git a/app/models/site_setting.rb b/app/models/site_setting.rb index 107e784a8b4..796fa16361d 100644 --- a/app/models/site_setting.rb +++ b/app/models/site_setting.rb @@ -158,6 +158,14 @@ class SiteSetting < ActiveRecord::Base SiteSetting.enable_s3_uploads ? SiteSetting.s3_endpoint : GlobalSetting.s3_endpoint end + def self.enable_s3_transfer_acceleration + if SiteSetting.enable_s3_uploads + SiteSetting.enable_s3_transfer_acceleration + else + GlobalSetting.enable_s3_transfer_acceleration + end + end + def self.enable_s3_uploads SiteSetting.enable_s3_uploads || GlobalSetting.use_s3? end diff --git a/config/discourse_defaults.conf b/config/discourse_defaults.conf index ce589d63b84..b0f9a466f1c 100644 --- a/config/discourse_defaults.conf +++ b/config/discourse_defaults.conf @@ -225,7 +225,7 @@ s3_cdn_url = s3_endpoint = s3_http_continue_timeout = s3_install_cors_rule = -s3_enable_transfer_acceleration = +enable_s3_transfer_acceleration = # Optionally, specify a separate CDN to be used for static JS assets stored on S3 s3_asset_cdn_url = diff --git a/lib/file_store/s3_store.rb b/lib/file_store/s3_store.rb index d89f3955ea7..f8768065129 100644 --- a/lib/file_store/s3_store.rb +++ b/lib/file_store/s3_store.rb @@ -25,7 +25,7 @@ module FileStore S3Helper.new( s3_bucket, Rails.configuration.multisite ? multisite_tombstone_prefix : TOMBSTONE_PREFIX, - use_accelerate_endpoint: SiteSetting.enable_s3_transfer_acceleration, + use_accelerate_endpoint: SiteSetting.Upload.enable_s3_transfer_acceleration, ) end diff --git a/lib/s3_helper.rb b/lib/s3_helper.rb index 93c9ca28841..1d50ce26bdb 100644 --- a/lib/s3_helper.rb +++ b/lib/s3_helper.rb @@ -47,15 +47,8 @@ class S3Helper setting_klass = use_db_s3_config ? SiteSetting : GlobalSetting options = S3Helper.s3_options(setting_klass) options[:client] = s3_client if s3_client.present? - use_accelerate_endpoint = - ( - if use_db_s3_config - SiteSetting.enable_s3_transfer_acceleration - else - GlobalSetting.s3_enable_transfer_acceleration - end - ) - options[:use_accelerate_endpoint] = !for_backup && use_accelerate_endpoint + options[:use_accelerate_endpoint] = !for_backup && + SiteSetting.Upload.enable_s3_transfer_acceleration bucket = if for_backup