From 5f0d38341e5983b6266b1756d1c9a44341e6e1cc Mon Sep 17 00:00:00 2001 From: Gerhard Schlager Date: Tue, 9 Jul 2019 17:34:41 +0200 Subject: [PATCH] FIX: Remapping during restore was wrong for CDN URLs --- lib/backup_restore/restorer.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/backup_restore/restorer.rb b/lib/backup_restore/restorer.rb index 75a1c90336a..c7ff9266d56 100644 --- a/lib/backup_restore/restorer.rb +++ b/lib/backup_restore/restorer.rb @@ -458,7 +458,7 @@ module BackupRestore def remap_uploads(previous_db_name, current_db_name) log "Remapping uploads..." - was_multisite = BackupMetadata.value_for("multisite") == "true" + was_multisite = BackupMetadata.value_for("multisite") == "t" uploads_folder = was_multisite ? "/" : "/uploads/#{current_db_name}/" if (old_base_url = BackupMetadata.value_for("base_url")) && old_base_url != Discourse.base_url @@ -476,16 +476,16 @@ module BackupRestore DbHelper.remap("#{old_s3_cdn_url}/", UrlHelper.schemaless("#{base_url}#{uploads_folder}")) old_host = URI.parse(old_s3_cdn_url).host - new_host = URI.parse(base_url.presence || Discourse.base_url).host + new_host = URI.parse(base_url).host DbHelper.remap(old_host, new_host) end if (old_cdn_url = BackupMetadata.value_for("cdn_url")) && old_cdn_url != Discourse.asset_host - base_url = SiteSetting.Upload.enable_s3_uploads ? SiteSetting.Upload.s3_base_url : Discourse.base_url + base_url = Discourse.asset_host || Discourse.base_url DbHelper.remap("#{old_cdn_url}/", UrlHelper.schemaless("#{base_url}/")) old_host = URI.parse(old_cdn_url).host - new_host = URI.parse(base_url.presence || Discourse.base_url).host + new_host = URI.parse(base_url).host DbHelper.remap(old_host, new_host) end