FIX: Upload.migrate_to_new_scheme undefined error when external image fails to download.

This commit is contained in:
Guo Xiang Tan 2019-03-28 15:58:42 +08:00
parent b5e32cfe2a
commit d0a1922ad9

View File

@ -239,12 +239,21 @@ class Upload < ActiveRecord::Base
# download if external # download if external
if external if external
url = SiteSetting.scheme + ":" + previous_url url = SiteSetting.scheme + ":" + previous_url
file = FileHelper.download(
url, begin
max_file_size: max_file_size_kb, retries ||= 0
tmp_file_name: "discourse",
follow_redirect: true file = FileHelper.download(
) rescue nil url,
max_file_size: max_file_size_kb,
tmp_file_name: "discourse",
follow_redirect: true
)
rescue OpenURI::HTTPError
retry if (retires += 1) < 1
next
end
path = file.path path = file.path
else else
path = local_store.path_for(upload) path = local_store.path_for(upload)