|
|
|
|
@ -14,7 +14,7 @@ import yaml
|
|
|
|
|
|
|
|
|
|
from contextlib import contextmanager
|
|
|
|
|
from hashlib import sha256
|
|
|
|
|
from http.client import IncompleteRead
|
|
|
|
|
from http.client import IncompleteRead, HTTPResponse
|
|
|
|
|
from urllib.error import URLError
|
|
|
|
|
from urllib.parse import urldefrag
|
|
|
|
|
from shutil import rmtree
|
|
|
|
|
@ -496,7 +496,7 @@ def _download_file(url, b_path, expected_hash, validate_certs, token=None, timeo
|
|
|
|
|
|
|
|
|
|
with open(b_file_path, 'wb') as download_file: # type: t.BinaryIO
|
|
|
|
|
try:
|
|
|
|
|
actual_hash = _consume_file(resp, write_to=download_file, length=resp.length)
|
|
|
|
|
actual_hash = _consume_file(resp, write_to=download_file)
|
|
|
|
|
except IncompleteRead as orig_exc:
|
|
|
|
|
raise AnsibleError(f"Downloading {url} failed") from orig_exc
|
|
|
|
|
|
|
|
|
|
@ -512,9 +512,10 @@ def _download_file(url, b_path, expected_hash, validate_certs, token=None, timeo
|
|
|
|
|
return b_file_path
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _consume_file(read_from: t.BinaryIO, write_to: t.BinaryIO = None, *, length: None | str | int = None) -> str:
|
|
|
|
|
def _consume_file(read_from: t.BinaryIO | HTTPResponse, write_to: t.BinaryIO | None = None) -> str:
|
|
|
|
|
bufsize = 65536
|
|
|
|
|
sha256_digest = sha256()
|
|
|
|
|
length = getattr(read_from, 'length', None)
|
|
|
|
|
actual_length = 0
|
|
|
|
|
remaining = None
|
|
|
|
|
while True:
|
|
|
|
|
|