Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/utils.py
Show First 20 Lines • Show All 118 Lines • ▼ Show 20 Lines | else: | ||||
response_data = response.iter_content(chunk_size=HASH_BLOCK_SIZE) | response_data = response.iter_content(chunk_size=HASH_BLOCK_SIZE) | ||||
filename = filename if filename else os.path.basename(urlsplit(url).path) | filename = filename if filename else os.path.basename(urlsplit(url).path) | ||||
logger.debug("filename: %s", filename) | logger.debug("filename: %s", filename) | ||||
filepath = os.path.join(dest, filename) | filepath = os.path.join(dest, filename) | ||||
logger.debug("filepath: %s", filepath) | logger.debug("filepath: %s", filepath) | ||||
h = MultiHash(hash_names=DOWNLOAD_HASHES) | h = MultiHash(hash_names=DOWNLOAD_HASHES | set(hashes.keys())) | ||||
with open(filepath, "wb") as f: | with open(filepath, "wb") as f: | ||||
for chunk in response_data: | for chunk in response_data: | ||||
h.update(chunk) | h.update(chunk) | ||||
f.write(chunk) | f.write(chunk) | ||||
response.close() | response.close() | ||||
# Also check the expected hashes if provided | # Also check the expected hashes if provided | ||||
▲ Show 20 Lines • Show All 50 Lines • Show Last 20 Lines |