From 503a11cc88f63a555a1afd9e2cc5f02708467c4f Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 10 Sep 2019 21:50:48 -0400 Subject: [PATCH] FIX: inline_uploads and subfolder (#8076) * FIX: inline_uploads and subfolder * if subfolder, also look for images with a path containing cdn_url + relative_url_root * FIX: migrate_to_s3 task and subfolder --- app/services/inline_uploads.rb | 5 ++++- lib/tasks/uploads.rake | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/services/inline_uploads.rb b/app/services/inline_uploads.rb index 039d5f37738..7ffa42943a1 100644 --- a/app/services/inline_uploads.rb +++ b/app/services/inline_uploads.rb @@ -282,7 +282,10 @@ class InlineUploads /(#{base_url}\/uploads\/#{db}#{UPLOAD_REGEXP_PATTERN})/, ] - regexps << /(#{cdn_url}\/uploads\/#{db}#{UPLOAD_REGEXP_PATTERN})/ if cdn_url + if cdn_url + regexps << /(#{cdn_url}\/uploads\/#{db}#{UPLOAD_REGEXP_PATTERN})/ + regexps << /(#{cdn_url}#{GlobalSetting.relative_url_root}\/uploads\/#{db}#{UPLOAD_REGEXP_PATTERN})/ unless GlobalSetting.relative_url_root.nil? + end if Discourse.store.external? if Rails.configuration.multisite diff --git a/lib/tasks/uploads.rake b/lib/tasks/uploads.rake index bf7b539b543..05b803026f8 100644 --- a/lib/tasks/uploads.rake +++ b/lib/tasks/uploads.rake @@ -306,7 +306,7 @@ def migrate_to_s3 puts "*" * 30 + " DRY RUN " + "*" * 30 if dry_run puts "Migrating uploads to S3 for '#{db}'..." - if Upload.by_users.where("url NOT LIKE '//%' AND url NOT LIKE '/uploads/#{db}/original/_X/%'").exists? + if Upload.by_users.where("url NOT LIKE '//%' AND url NOT LIKE '#{GlobalSetting.relative_url_root}/uploads/#{db}/original/_X/%'").exists? puts <<~TEXT Some uploads were not migrated to the new scheme. Please run these commands in the rails console