From f0b35b2fe21234602c3e20a031bcadb5c9c334e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Tue, 19 May 2015 12:39:46 +0200 Subject: [PATCH] FIX: file helper to download file using chunks of 512KB --- lib/file_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/file_helper.rb b/lib/file_helper.rb index 9a2b18b24a1..008dc55216e 100644 --- a/lib/file_helper.rb +++ b/lib/file_helper.rb @@ -15,11 +15,11 @@ class FileHelper File.open(tmp.path, "wb") do |f| downloaded = uri.open("rb", read_timeout: 5, redirect: follow_redirect) - while f.size <= max_file_size && data = downloaded.read(max_file_size) + while f.size <= max_file_size && data = downloaded.read(512.kilobytes) f.write(data) end # tiny files are StringIO, no close! on them - downloaded.close! if downloaded.respond_to? :close! + downloaded.try(:close!) rescue nil end tmp