From 27d71f2727c661c42090fcb40c262fbce95dc391 Mon Sep 17 00:00:00 2001 From: evazion Date: Mon, 14 Feb 2022 22:39:23 -0600 Subject: [PATCH] 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. --- app/logical/sources/strategies/base.rb | 10 ++++------ app/logical/sources/strategies/lofter.rb | 4 ---- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/app/logical/sources/strategies/base.rb b/app/logical/sources/strategies/base.rb index e17aa9541..84a4c628b 100644 --- a/app/logical/sources/strategies/base.rb +++ b/app/logical/sources/strategies/base.rb @@ -18,6 +18,9 @@ module Sources class Base 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 extend Memoist @@ -228,14 +231,9 @@ module Sources end memoize :http - # The http timeout to download a file. Overrideable by each site - def download_timeout - 30 - end - # A http client for downloading files. 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 memoize :http_downloader diff --git a/app/logical/sources/strategies/lofter.rb b/app/logical/sources/strategies/lofter.rb index 870c945a5..5272d44c3 100644 --- a/app/logical/sources/strategies/lofter.rb +++ b/app/logical/sources/strategies/lofter.rb @@ -103,10 +103,6 @@ module Sources def artist_name urls.map { |u| u[PROFILE_URL, :artist_name] || u[PAGE_URL, :artist_name] }.compact.first end - - def download_timeout - 60 - end end end end