Add retries to some online audit checks

This commit is contained in:
Bo Anderson 2023-10-14 17:41:47 +01:00
parent fbe50bf280
commit e80bb70bed
No known key found for this signature in database
GPG Key ID: 3DB94E204E137D65
2 changed files with 19 additions and 3 deletions

View File

@ -149,7 +149,13 @@ module Homebrew
problem http_content_problem
end
elsif strategy <= GitDownloadStrategy
problem "The URL #{url} is not a valid git URL" unless Utils::Git.remote_exists? url
attempts = 0
remote_exists = T.let(false, T::Boolean)
while !remote_exists && attempts < Homebrew::EnvConfig.curl_retries.to_i
remote_exists = Utils::Git.remote_exists?(url)
attempts += 1
end
problem "The URL #{url} is not a valid git URL" unless remote_exists
elsif strategy <= SubversionDownloadStrategy
next unless DevelopmentTools.subversion_handles_most_https_certificates?
next unless Utils::Svn.available?

View File

@ -298,9 +298,10 @@ module Utils
end
details = T.let(nil, T.nilable(T::Hash[Symbol, T.untyped]))
attempts = 0
user_agents.each do |user_agent|
details =
curl_http_content_headers_and_checksum(
loop do
details = curl_http_content_headers_and_checksum(
url,
specs: specs,
hash_needed: hash_needed,
@ -308,6 +309,14 @@ module Utils
user_agent: user_agent,
referer: referer,
)
# Retry on network issues
break if details[:exit_status] != 52 && details[:exit_status] != 56
attempts += 1
break if attempts >= Homebrew::EnvConfig.curl_retries.to_i
end
break if http_status_ok?(details[:status_code])
end
@ -453,6 +462,7 @@ module Utils
{
url: url,
final_url: final_url,
exit_status: status.exitstatus,
status_code: status_code,
headers: headers,
etag: etag,