From 5be26c7d24a660f72de91fe3e60f5b6d48ef43aa Mon Sep 17 00:00:00 2001 From: Sam Saffron Date: Thu, 13 Aug 2020 13:48:11 +1000 Subject: [PATCH] DEV: add error handling in case download fails --- lib/tasks/uploads.rake | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/tasks/uploads.rake b/lib/tasks/uploads.rake index 7203e533606..55e17d07b70 100644 --- a/lib/tasks/uploads.rake +++ b/lib/tasks/uploads.rake @@ -1071,7 +1071,14 @@ def fix_missing_s3 ids.each do |id| upload = Upload.find(id) - tempfile = FileHelper.download(upload.url, max_file_size: 30.megabyte, tmp_file_name: "#{SecureRandom.hex}.#{upload.extension}") + tempfile = nil + + begin + tempfile = FileHelper.download(upload.url, max_file_size: 30.megabyte, tmp_file_name: "#{SecureRandom.hex}.#{upload.extension}") + rescue => e + puts "Failed to download #{upload.url} #{e}" + end + if tempfile puts "Successfully downloaded upload id: #{upload.id} - #{upload.url} fixing upload"