uploads: fix uploading from source not working.

ref: 26ad844bbe (r40077579).
This commit is contained in:
evazion
2020-06-22 15:32:48 -05:00
parent b904c01d69
commit db3407caa3
2 changed files with 71 additions and 28 deletions

View File

@@ -39,7 +39,7 @@ module Sources
def initialize(url, referer_url = nil)
@url = url.to_s
@referer_url = referer_url&.to_s
@urls = [url, referer_url].select(&:present?)
@urls = [@url, @referer_url].select(&:present?)
@parsed_url = Addressable::URI.heuristic_parse(url) rescue nil
@parsed_referer = Addressable::URI.heuristic_parse(referer_url) rescue nil
@@ -152,6 +152,7 @@ module Sources
# Download the file at the given url, or at the main image url by default.
def download_file!(download_url = image_url)
raise DownloadError, "Download failed: couldn't find download url for #{url}" if download_url.blank?
response, file = http.download_media(download_url)
raise DownloadError, "Download failed: #{download_url} returned error #{response.status}" if response.status != 200
file