From 68b640f6a9a2631294e1b93a8c2c59171d36756a Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Thu, 15 Nov 2018 15:10:39 +0800 Subject: [PATCH] Allow `s3:upload_assets` to use site settings from DB take 2. --- lib/tasks/s3.rake | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/tasks/s3.rake b/lib/tasks/s3.rake index 867a9a470cb..34fb4ef6ceb 100644 --- a/lib/tasks/s3.rake +++ b/lib/tasks/s3.rake @@ -37,8 +37,18 @@ def upload(path, remote_path, content_type, content_encoding = nil) end end +def use_db_s3_config + ENV["USE_DB_S3_CONFIG"] +end + def helper - @helper ||= S3Helper.new(GlobalSetting.s3_bucket.downcase, '', S3Helper.s3_options(GlobalSetting)) + @helper ||= begin + setting = use_db_s3_config ? SiteSetting : GlobalSetting + + S3Helper.new( + setting.s3_bucket.downcase, '', S3Helper.s3_options(setting) + ) + end end def assets @@ -76,7 +86,7 @@ def asset_paths end def ensure_s3_configured! - unless GlobalSetting.use_s3? || ENV["USE_DB_S3_CONFIG"] + unless GlobalSetting.use_s3? || use_db_s3_config STDERR.puts "ERROR: Ensure S3 is configured in config/discourse.conf of environment vars" exit 1 end