mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 20:04:16 +08:00
FIX: Don't migrate custom emojis that are no longer valid.
* Warn about failed migration in logs.
This commit is contained in:
parent
ad8a579c79
commit
566f367fc3
|
@ -3,7 +3,6 @@ module Jobs
|
|||
def execute_onceoff(args)
|
||||
return if Rails.env.test?
|
||||
|
||||
CustomEmoji.transaction do
|
||||
Dir["#{Rails.root}/#{Emoji.base_directory}/*.{png,gif}"].each do |path|
|
||||
name = File.basename(path, File.extname(path))
|
||||
|
||||
|
@ -17,9 +16,13 @@ module Jobs
|
|||
)
|
||||
|
||||
if upload.persisted?
|
||||
CustomEmoji.create!(name: name, upload: upload)
|
||||
custom_emoji = CustomEmoji.new(name: name, upload: upload)
|
||||
|
||||
if !custom_emoji.save
|
||||
warn("Failed to create custom emoji '#{name}': #{custom_emoji.errors.full_messages}")
|
||||
end
|
||||
else
|
||||
raise "Failed to create upload for '#{name}' custom emoji"
|
||||
warn("Failed to create upload for '#{name}' custom emoji: #{upload.errors.full_messages}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -30,6 +33,9 @@ module Jobs
|
|||
post.rebake!
|
||||
end
|
||||
end
|
||||
|
||||
def warn(message)
|
||||
Rails.logger.warn(message)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user