mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 09:42:07 +08:00
FIX: Upload.migrate_to_new_scheme
undefined error when external image fails to download.
This commit is contained in:
parent
b5e32cfe2a
commit
d0a1922ad9
|
@ -239,12 +239,21 @@ class Upload < ActiveRecord::Base
|
|||
# download if external
|
||||
if external
|
||||
url = SiteSetting.scheme + ":" + previous_url
|
||||
file = FileHelper.download(
|
||||
url,
|
||||
max_file_size: max_file_size_kb,
|
||||
tmp_file_name: "discourse",
|
||||
follow_redirect: true
|
||||
) rescue nil
|
||||
|
||||
begin
|
||||
retries ||= 0
|
||||
|
||||
file = FileHelper.download(
|
||||
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
|
||||
else
|
||||
path = local_store.path_for(upload)
|
||||
|
|
Loading…
Reference in New Issue
Block a user