Merge pull request #7885 from Bo98/update-license-data
dev-cmd/update-license-data: don't use partial downloading & fix --fail-if-changed
This commit is contained in:
commit
524301b733
File diff suppressed because it is too large
Load Diff
@ -30,10 +30,10 @@ module Homebrew
|
||||
def update_license_data
|
||||
update_license_data_args.parse
|
||||
ohai "Updating SPDX license data..."
|
||||
curl_download(SPDX_DATA_URL, to: SPDX_PATH)
|
||||
curl_download(SPDX_DATA_URL, to: SPDX_PATH, partial: false)
|
||||
|
||||
return unless args.fail_if_changed?
|
||||
|
||||
system("git diff --stat --exit-code #{SPDX_PATH}")
|
||||
safe_system "git", "diff", "--stat", "--exit-code", SPDX_PATH
|
||||
end
|
||||
end
|
||||
|
||||
@ -54,21 +54,25 @@ def curl(*args, secrets: [], **options)
|
||||
secrets: secrets
|
||||
end
|
||||
|
||||
def curl_download(*args, to: nil, **options)
|
||||
def curl_download(*args, to: nil, partial: true, **options)
|
||||
destination = Pathname(to)
|
||||
destination.dirname.mkpath
|
||||
|
||||
range_stdout = curl_output("--location", "--range", "0-1",
|
||||
"--dump-header", "-",
|
||||
"--write-out", "%\{http_code}",
|
||||
"--output", "/dev/null", *args, **options).stdout
|
||||
headers, _, http_status = range_stdout.partition("\r\n\r\n")
|
||||
if partial
|
||||
range_stdout = curl_output("--location", "--range", "0-1",
|
||||
"--dump-header", "-",
|
||||
"--write-out", "%\{http_code}",
|
||||
"--output", "/dev/null", *args, **options).stdout
|
||||
headers, _, http_status = range_stdout.partition("\r\n\r\n")
|
||||
|
||||
supports_partial_download = http_status.to_i == 206 # Partial Content
|
||||
if supports_partial_download &&
|
||||
destination.exist? &&
|
||||
destination.size == %r{^.*Content-Range: bytes \d+-\d+/(\d+)\r\n.*$}m.match(headers)&.[](1)&.to_i
|
||||
return # We've already downloaded all the bytes
|
||||
supports_partial_download = http_status.to_i == 206 # Partial Content
|
||||
if supports_partial_download &&
|
||||
destination.exist? &&
|
||||
destination.size == %r{^.*Content-Range: bytes \d+-\d+/(\d+)\r\n.*$}m.match(headers)&.[](1)&.to_i
|
||||
return # We've already downloaded all the bytes
|
||||
end
|
||||
else
|
||||
supports_partial_download = false
|
||||
end
|
||||
|
||||
continue_at = if destination.exist? && supports_partial_download
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user