fix async processing for ugoira
This commit is contained in:
@@ -17,7 +17,7 @@ module Downloads
|
||||
end
|
||||
|
||||
# http://i2.pixiv.net/img-zip-ugoira/img/2014/08/05/06/01/10/44524589_ugoira1920x1080.zip
|
||||
if url =~ %r!\Ahttps?://i[12]\.pixiv\.net/img-zip-ugoira/img/\d{4}/\d{2}/\d{2}/\d{2}/\d{2}/\d{2}/\d+_ugoira\d+x\d+\.zip\z!i
|
||||
if url =~ %r!\Ahttps?://i\d+\.pixiv\.net/img-zip-ugoira/img/\d{4}/\d{2}/\d{2}/\d{2}/\d{2}/\d{2}/\d+_ugoira\d+x\d+\.zip\z!i
|
||||
data[:ugoira_frame_data] = source.ugoira_frame_data
|
||||
data[:ugoira_width] = source.ugoira_width
|
||||
data[:ugoira_height] = source.ugoira_height
|
||||
|
||||
@@ -10,7 +10,8 @@ class PixivUgoiraService
|
||||
end
|
||||
|
||||
def generate_resizes(source_path, output_path, preview_path)
|
||||
PixivUgoiraConverter.delay(:queue => Socket.gethostname).convert(source_path, output_path, preview_path, @frame_data)
|
||||
# Run this a bit in the future to give the upload process time to move the file
|
||||
PixivUgoiraConverter.delay(:queue => Socket.gethostname, :run_at => 2.seconds.from_now).convert(source_path, output_path, preview_path, @frame_data)
|
||||
|
||||
# since the resizes will be delayed, just touch the output file so the
|
||||
# file distribution wont break
|
||||
|
||||
@@ -241,7 +241,8 @@ class Upload < ActiveRecord::Base
|
||||
if is_image?
|
||||
Danbooru.resize(source_path, output_path, width, height, quality)
|
||||
elsif is_ugoira?
|
||||
ugoira_service.generate_resizes(source_path, resized_file_path_for(Danbooru.config.large_image_width), resized_file_path_for(Danbooru.config.small_image_width))
|
||||
# by the time this runs we'll have moved source_path to md5_file_path
|
||||
ugoira_service.generate_resizes(md5_file_path, resized_file_path_for(Danbooru.config.large_image_width), resized_file_path_for(Danbooru.config.small_image_width))
|
||||
elsif is_video?
|
||||
generate_video_preview_for(width, height, output_path)
|
||||
end
|
||||
@@ -374,7 +375,7 @@ class Upload < ActiveRecord::Base
|
||||
self.file_path = destination_path
|
||||
download = Downloads::File.new(source, destination_path, :is_ugoira => has_ugoira_tag?)
|
||||
download.download!
|
||||
ugoira_service.load(download.data)
|
||||
ugoira_service.load(download.data) if has_ugoira_tag?
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user