mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Try to download missing uploads from origin URL (#15629)
This commit is contained in:
parent
3050fe893b
commit
27f1630b01
@ -1010,15 +1010,26 @@ def fix_missing_s3
|
|||||||
next if !upload
|
next if !upload
|
||||||
|
|
||||||
tempfile = nil
|
tempfile = nil
|
||||||
|
downloaded_from = nil
|
||||||
|
|
||||||
begin
|
begin
|
||||||
tempfile = FileHelper.download(upload.url, max_file_size: 30.megabyte, tmp_file_name: "#{SecureRandom.hex}.#{upload.extension}")
|
tempfile = FileHelper.download(upload.url, max_file_size: 30.megabyte, tmp_file_name: "#{SecureRandom.hex}.#{upload.extension}")
|
||||||
|
downloaded_from = upload.url
|
||||||
rescue => e
|
rescue => e
|
||||||
puts "Failed to download #{upload.url} #{e}"
|
if upload.origin.present?
|
||||||
|
begin
|
||||||
|
tempfile = FileHelper.download(upload.origin, max_file_size: 30.megabyte, tmp_file_name: "#{SecureRandom.hex}.#{upload.extension}")
|
||||||
|
downloaded_from = upload.origin
|
||||||
|
rescue => e
|
||||||
|
puts "Failed to download #{upload.origin} #{e}"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
puts "Failed to download #{upload.url} #{e}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if tempfile
|
if tempfile
|
||||||
puts "Successfully downloaded upload id: #{upload.id} - #{upload.url} fixing upload"
|
puts "Successfully downloaded upload id: #{upload.id} - #{downloaded_from} fixing upload"
|
||||||
|
|
||||||
fixed_upload = nil
|
fixed_upload = nil
|
||||||
fix_error = nil
|
fix_error = nil
|
||||||
|
Loading…
Reference in New Issue
Block a user