mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Significantly improve fetch speed of bottles
This commit is contained in:
parent
8d9aa9070a
commit
6d8b033eff
@ -628,8 +628,10 @@ class CurlGitHubPackagesDownloadStrategy < CurlDownloadStrategy
|
||||
|
||||
private
|
||||
|
||||
def resolved_basename
|
||||
@resolved_basename.presence || super
|
||||
def resolve_url_basename_time_file_size(url, timeout: nil)
|
||||
return super if @resolved_basename.blank?
|
||||
|
||||
[url, @resolved_basename, nil, nil, false]
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -36,11 +36,11 @@ describe CurlDownloadStrategy do
|
||||
|
||||
it "calls curl with default arguments" do
|
||||
expect(strategy).to receive(:curl).with(
|
||||
"--remote-time",
|
||||
"--output", an_instance_of(Pathname),
|
||||
# example.com supports partial requests.
|
||||
"--continue-at", "-",
|
||||
"--location",
|
||||
"--remote-time",
|
||||
"--output", an_instance_of(Pathname),
|
||||
url,
|
||||
an_instance_of(Hash)
|
||||
)
|
||||
|
@ -173,9 +173,9 @@ module Utils
|
||||
destination = Pathname(to)
|
||||
destination.dirname.mkpath
|
||||
|
||||
args = ["--location", "--remote-time", "--output", destination, *args]
|
||||
args = ["--location", *args]
|
||||
|
||||
if try_partial
|
||||
if try_partial && destination.exist?
|
||||
headers = begin
|
||||
parsed_output = curl_headers(*args, **options, wanted_headers: ["accept-ranges"])
|
||||
parsed_output.fetch(:responses).last&.fetch(:headers) || {}
|
||||
@ -189,7 +189,7 @@ module Utils
|
||||
supports_partial = headers.fetch("accept-ranges", "none") != "none"
|
||||
content_length = headers["content-length"]&.to_i
|
||||
|
||||
if supports_partial && destination.exist?
|
||||
if supports_partial
|
||||
# We've already downloaded all bytes.
|
||||
return if destination.size == content_length
|
||||
|
||||
@ -197,6 +197,8 @@ module Utils
|
||||
end
|
||||
end
|
||||
|
||||
args = ["--remote-time", "--output", destination, *args]
|
||||
|
||||
curl(*args, **options)
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user