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.
This commit is contained in:
Guo Xiang Tan 2019-04-03 11:39:49 +08:00
parent 0de2253d55
commit 4037a2fd0b
1 changed files with 1 additions and 2 deletions

View File

@ -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