Pass verbosity options to curl in download strategies.

This commit is contained in:
Markus Reiter 2020-09-10 23:50:24 +02:00
parent 16acd08d0a
commit 172bf76d74
2 changed files with 13 additions and 6 deletions

View File

@ -120,12 +120,18 @@ class AbstractDownloadStrategy
def command!(*args, **options)
system_command!(
*args,
env: env.merge(options.fetch(:env, {})),
**command_output_options,
**options,
)
end
def command_output_options
{
print_stdout: !quiet?,
print_stderr: !quiet?,
verbose: verbose? && !quiet?,
env: env,
**options,
)
}
end
def env
@ -484,7 +490,7 @@ class CurlDownloadStrategy < AbstractFileDownloadStrategy
def curl(*args, **options)
args << "--connect-timeout" << "15" unless mirrors.empty?
super(*_curl_args, *args, **_curl_opts, **options)
super(*_curl_args, *args, **_curl_opts, **command_output_options, **options)
end
end

View File

@ -44,18 +44,19 @@ def curl_args(*extra_args, show_output: false, user_agent: :default)
args + extra_args
end
def curl_with_workarounds(*args, secrets: nil, print_stdout: nil, print_stderr: nil, env: {}, **options)
def curl_with_workarounds(*args, secrets: nil, print_stdout: nil, print_stderr: nil, verbose: nil, env: {}, **options)
command_options = {
secrets: secrets,
print_stdout: print_stdout,
print_stderr: print_stderr,
verbose: verbose,
}.compact
# SSL_CERT_FILE can be incorrectly set by users or portable-ruby and screw
# with SSL downloads so unset it here.
result = system_command curl_executable,
args: curl_args(*args, **options),
env: env.merge({ "SSL_CERT_FILE" => nil }),
env: { "SSL_CERT_FILE" => nil }.merge(env),
**command_options
if !result.success? && !args.include?("--http1.1")