uploads: raise download timeout.

Raise the timeout for downloading files from the source to 60 seconds globally.

Previously had a lower timeout because uploads were processed in the
foreground when not using the bookmarklet, and we didn't want to tie up
Puma worker processes with slow downloads. Now that all uploads are
processed in the background, we can have a higher timeout.
This commit is contained in:
evazion
2022-02-14 22:39:23 -06:00
parent 02edb52569
commit 27d71f2727
2 changed files with 4 additions and 10 deletions

View File

@@ -18,6 +18,9 @@ module Sources
class Base class Base
class DownloadError < StandardError; end class DownloadError < StandardError; end
# The http timeout to download a file.
DOWNLOAD_TIMEOUT = 60
attr_reader :url, :referer_url, :urls, :parsed_url, :parsed_referer, :parsed_urls attr_reader :url, :referer_url, :urls, :parsed_url, :parsed_referer, :parsed_urls
extend Memoist extend Memoist
@@ -228,14 +231,9 @@ module Sources
end end
memoize :http memoize :http
# The http timeout to download a file. Overrideable by each site
def download_timeout
30
end
# A http client for downloading files. # A http client for downloading files.
def http_downloader def http_downloader
http.timeout(download_timeout).max_size(Danbooru.config.max_file_size).use(:spoof_referrer).use(:unpolish_cloudflare) http.timeout(DOWNLOAD_TIMEOUT).max_size(Danbooru.config.max_file_size).use(:spoof_referrer).use(:unpolish_cloudflare)
end end
memoize :http_downloader memoize :http_downloader

View File

@@ -103,10 +103,6 @@ module Sources
def artist_name def artist_name
urls.map { |u| u[PROFILE_URL, :artist_name] || u[PAGE_URL, :artist_name] }.compact.first urls.map { |u| u[PROFILE_URL, :artist_name] || u[PAGE_URL, :artist_name] }.compact.first
end end
def download_timeout
60
end
end end
end end
end end