From cbc3b48778dc8235e694097416e8c6d1aaa90dec Mon Sep 17 00:00:00 2001 From: Toks Date: Fri, 17 Oct 2014 00:21:47 -0400 Subject: [PATCH] Fix zip file not being closed file.get_input_stream leaves the file open by default, which means the zip cannot be moved later on. But the block version of it closes the file automatically. --- app/logical/pixiv_ugoira_converter.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/logical/pixiv_ugoira_converter.rb b/app/logical/pixiv_ugoira_converter.rb index 37deb51ba..75be6cfaa 100644 --- a/app/logical/pixiv_ugoira_converter.rb +++ b/app/logical/pixiv_ugoira_converter.rb @@ -10,7 +10,7 @@ class PixivUgoiraConverter FileUtils.mkdir_p("#{tmpdir}/images") folder.each_with_index do |file, i| path = File.join(tmpdir, "images", file.name) - image_blob = file.get_input_stream.read + image_blob = file.get_input_stream {|is| is.read} File.open(path, "wb") do |f| f.write(image_blob) end @@ -46,7 +46,7 @@ class PixivUgoiraConverter def write_preview(folder, path) file = folder.first - image_blob = file.get_input_stream.read + image_blob = file.get_input_stream {|is| is.read} image = Magick::Image.from_blob(image_blob).first image.write(path) end