FIX: Use GlobalSetting values instead of ENV variables in migrate_to_s3

TIL how GlobalSetting works in sync with environment variables
Also fixes a small bug where bucket value was being used when it could have been nil
This commit is contained in:
Rishabh 2019-01-16 14:37:05 +05:30
parent f06b773d25
commit 60790eb006
1 changed files with 2 additions and 2 deletions

View File

@ -214,7 +214,6 @@ def migrate_to_s3
db = RailsMultisite::ConnectionManagement.current_db
dry_run = !!ENV["DRY_RUN"]
bucket_has_folder_path = true if ENV["DISCOURSE_S3_BUCKET"].include? "/"
puts "*" * 30 + " DRY RUN " + "*" * 30 if dry_run
puts "Migrating uploads to S3 for '#{db}'..."
@ -245,10 +244,11 @@ def migrate_to_s3
exit 3
end
bucket_has_folder_path = true if GlobalSetting.s3_bucket.include? "/"
s3 = Aws::S3::Client.new(S3Helper.s3_options(GlobalSetting))
if bucket_has_folder_path
bucket, folder = S3Helper.get_bucket_and_folder_path(ENV["DISCOURSE_S3_BUCKET"])
bucket, folder = S3Helper.get_bucket_and_folder_path(GlobalSetting.s3_bucket)
folder = File.join(folder, "/")
else
bucket, folder = GlobalSetting.s3_bucket, ""