FIX: Use GlobalSetting values instead of ENV variables in migrate_to_s3

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

diff --git a/lib/tasks/uploads.rake b/lib/tasks/uploads.rake
index 9f850ab..37b5425 100644
--- a/lib/tasks/uploads.rake
+++ b/lib/tasks/uploads.rake
@@ -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, ""

GitHub sha: 60790eb0

1 Like

This commit has been mentioned on Discourse Meta. There might be relevant details there:

This commit has been mentioned on Discourse Meta. There might be relevant details there:

FIX: Use ENV values instead of 'S3Helper.s3_options' in migrate_to_s3