DEV: Put a mutex around `Upload.migrate_to_new_scheme`.
This ensures that only one migration is running at any given point in time across the instances.
This commit is contained in:
parent
55f406bb79
commit
3c9495b989
|
@ -205,12 +205,19 @@ class Upload < ActiveRecord::Base
|
|||
def self.migrate_to_new_scheme(limit: nil)
|
||||
problems = []
|
||||
|
||||
DistributedMutex.synchronize("migrate_upload_to_new_scheme") do
|
||||
if SiteSetting.migrate_to_new_scheme
|
||||
max_file_size_kb = [SiteSetting.max_image_size_kb, SiteSetting.max_attachment_size_kb].max.kilobytes
|
||||
max_file_size_kb = [
|
||||
SiteSetting.max_image_size_kb,
|
||||
SiteSetting.max_attachment_size_kb
|
||||
].max.kilobytes
|
||||
|
||||
local_store = FileStore::LocalStore.new
|
||||
db = RailsMultisite::ConnectionManagement.current_db
|
||||
|
||||
scope = Upload.by_users.where("url NOT LIKE '%/original/_X/%' AND url LIKE '%/uploads/#{db}%'").order(id: :desc)
|
||||
scope = Upload.by_users
|
||||
.where("url NOT LIKE '%/original/_X/%' AND url LIKE '%/uploads/#{db}%'")
|
||||
.order(id: :desc)
|
||||
|
||||
scope = scope.limit(limit) if limit
|
||||
|
||||
|
@ -299,6 +306,7 @@ class Upload < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
problems
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue