DEV: add error handling in case download fails

This commit is contained in:
Sam Saffron 2020-08-13 13:48:11 +10:00
parent 787ad7d84d
commit 5be26c7d24
No known key found for this signature in database
GPG Key ID: B9606168D2FFD9F5
1 changed files with 8 additions and 1 deletions

View File

@ -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"