Merge pull request #3039 from reitermarkus/curl-args
`curl_download`: Retry once on error `33`.
This commit is contained in:
commit
d6d681ca01
@ -11,7 +11,6 @@ end
|
|||||||
def curl_args(*extra_args, show_output: false, user_agent: :default)
|
def curl_args(*extra_args, show_output: false, user_agent: :default)
|
||||||
args = [
|
args = [
|
||||||
curl_executable.to_s,
|
curl_executable.to_s,
|
||||||
"--fail",
|
|
||||||
"--show-error",
|
"--show-error",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -25,6 +24,7 @@ def curl_args(*extra_args, show_output: false, user_agent: :default)
|
|||||||
end
|
end
|
||||||
|
|
||||||
unless show_output
|
unless show_output
|
||||||
|
args << "--fail"
|
||||||
args << "--progress-bar" unless ARGV.verbose?
|
args << "--progress-bar" unless ARGV.verbose?
|
||||||
args << "--verbose" if ENV["HOMEBREW_CURL_VERBOSE"]
|
args << "--verbose" if ENV["HOMEBREW_CURL_VERBOSE"]
|
||||||
args << "--silent" if !$stdout.tty? || ENV["TRAVIS"]
|
args << "--silent" if !$stdout.tty? || ENV["TRAVIS"]
|
||||||
@ -38,7 +38,16 @@ def curl(*args)
|
|||||||
end
|
end
|
||||||
|
|
||||||
def curl_download(*args, to: nil, **options)
|
def curl_download(*args, to: nil, **options)
|
||||||
curl("--location", "--remote-time", "--continue-at", "-", "--output", to, *args, **options)
|
continue_at ||= "-"
|
||||||
|
curl("--location", "--remote-time", "--continue-at", continue_at, "--output", to, *args, **options)
|
||||||
|
rescue ErrorDuringExecution
|
||||||
|
# `curl` error 33: HTTP server doesn't seem to support byte ranges. Cannot resume.
|
||||||
|
if $CHILD_STATUS.exitstatus == 33 && continue_at == "-"
|
||||||
|
continue_at = "0"
|
||||||
|
retry
|
||||||
|
end
|
||||||
|
|
||||||
|
raise
|
||||||
end
|
end
|
||||||
|
|
||||||
def curl_output(*args, **options)
|
def curl_output(*args, **options)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user