From 4037a2fd0b37ebd772b5c396b18ef710b02437a9 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Wed, 3 Apr 2019 11:39:49 +0800 Subject: [PATCH] FIX: Restrict scope of old scheme upload migration. Some sites have external URLs that don't even match `%/uploads/%' and some sites surprise me with URLs that contains the default path when it is a site in a multisite cluster. We can't do anything about those. --- app/models/upload.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/models/upload.rb b/app/models/upload.rb index 0e5fef584c..d803e2fd50 100644 --- a/app/models/upload.rb +++ b/app/models/upload.rb @@ -224,8 +224,7 @@ class Upload < ActiveRecord::Base max_file_size_kb = [SiteSetting.max_image_size_kb, SiteSetting.max_attachment_size_kb].max.kilobytes local_store = FileStore::LocalStore.new - scope = Upload.by_users - .where("url NOT LIKE '%/original/_X/%'") + scope = Upload.by_users.where("url NOT LIKE '%/original/_X/%' AND url LIKE '%/uploads/#{RailsMultisite::ConnectionManagement.current_db}%'") .order(id: :desc) scope = scope.limit(limit) if limit