FIX: Allow restoring non-subfolder backup to subfolder site (#12537)

FIX: Allow restoring non-subfolder backup to subfolder site (#12537)

GlobalSetting.relative_url_root comes from the destination site. We can’t be sure whether it was the same on the original site. It’s safer to use a wildcard here, so we can backup/restore sites with different relative_url_root values.

diff --git a/lib/file_store/to_s3_migration.rb b/lib/file_store/to_s3_migration.rb
index 85af5a5..9af8aa3 100644
--- a/lib/file_store/to_s3_migration.rb
+++ b/lib/file_store/to_s3_migration.rb
@@ -135,8 +135,8 @@ module FileStore
     end
 
     def uploads_migrated_to_new_scheme?
-      seeded_image_url = "#{GlobalSetting.relative_url_root}/uploads/#{@current_db}/original/_X/"
-      !Upload.by_users.where("url NOT LIKE '//%' AND url NOT LIKE '#{seeded_image_url}%'").exists?
+      seeded_image_url = "uploads/#{@current_db}/original/_X/"
+      !Upload.by_users.where("url NOT LIKE '//%' AND url NOT LIKE '/%#{seeded_image_url}%'").exists?
     end
 
     def migrate_to_s3

GitHub sha: 35e1e009

This commit appears in #12537 which was approved by gschlager. It was merged by SamSaffron.