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
|
private
|
||||||
|
|
||||||
def resolved_basename
|
def resolve_url_basename_time_file_size(url, timeout: nil)
|
||||||
@resolved_basename.presence || super
|
return super if @resolved_basename.blank?
|
||||||
|
|
||||||
|
[url, @resolved_basename, nil, nil, false]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -36,11 +36,11 @@ describe CurlDownloadStrategy do
|
|||||||
|
|
||||||
it "calls curl with default arguments" do
|
it "calls curl with default arguments" do
|
||||||
expect(strategy).to receive(:curl).with(
|
expect(strategy).to receive(:curl).with(
|
||||||
|
"--remote-time",
|
||||||
|
"--output", an_instance_of(Pathname),
|
||||||
# example.com supports partial requests.
|
# example.com supports partial requests.
|
||||||
"--continue-at", "-",
|
"--continue-at", "-",
|
||||||
"--location",
|
"--location",
|
||||||
"--remote-time",
|
|
||||||
"--output", an_instance_of(Pathname),
|
|
||||||
url,
|
url,
|
||||||
an_instance_of(Hash)
|
an_instance_of(Hash)
|
||||||
)
|
)
|
||||||
|
@ -173,9 +173,9 @@ module Utils
|
|||||||
destination = Pathname(to)
|
destination = Pathname(to)
|
||||||
destination.dirname.mkpath
|
destination.dirname.mkpath
|
||||||
|
|
||||||
args = ["--location", "--remote-time", "--output", destination, *args]
|
args = ["--location", *args]
|
||||||
|
|
||||||
if try_partial
|
if try_partial && destination.exist?
|
||||||
headers = begin
|
headers = begin
|
||||||
parsed_output = curl_headers(*args, **options, wanted_headers: ["accept-ranges"])
|
parsed_output = curl_headers(*args, **options, wanted_headers: ["accept-ranges"])
|
||||||
parsed_output.fetch(:responses).last&.fetch(:headers) || {}
|
parsed_output.fetch(:responses).last&.fetch(:headers) || {}
|
||||||
@ -189,7 +189,7 @@ module Utils
|
|||||||
supports_partial = headers.fetch("accept-ranges", "none") != "none"
|
supports_partial = headers.fetch("accept-ranges", "none") != "none"
|
||||||
content_length = headers["content-length"]&.to_i
|
content_length = headers["content-length"]&.to_i
|
||||||
|
|
||||||
if supports_partial && destination.exist?
|
if supports_partial
|
||||||
# We've already downloaded all bytes.
|
# We've already downloaded all bytes.
|
||||||
return if destination.size == content_length
|
return if destination.size == content_length
|
||||||
|
|
||||||
@ -197,6 +197,8 @@ module Utils
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
args = ["--remote-time", "--output", destination, *args]
|
||||||
|
|
||||||
curl(*args, **options)
|
curl(*args, **options)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user