mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 01:25:54 +08:00
24 lines
597 B
Ruby
24 lines
597 B
Ruby
|
# frozen_string_literal: true
|
||
|
|
||
|
module Jobs
|
||
|
class UpdateAnimatedUploads < ::Jobs::Scheduled
|
||
|
every 1.hour
|
||
|
|
||
|
MAX_PROCESSED_GIF_IMAGES ||= 200
|
||
|
|
||
|
def execute(args)
|
||
|
Upload
|
||
|
.where("extension = 'gif' OR (extension IS NULL AND original_filename LIKE '%.gif')")
|
||
|
.where(animated: nil)
|
||
|
.limit(MAX_PROCESSED_GIF_IMAGES)
|
||
|
.each do |upload|
|
||
|
uri = Discourse.store.path_for(upload) || upload.url
|
||
|
upload.update!(animated: FastImage.animated?(uri))
|
||
|
upload.optimized_images.destroy_all if upload.animated
|
||
|
end
|
||
|
|
||
|
nil
|
||
|
end
|
||
|
end
|
||
|
end
|