Update hash method

This commit is contained in:
Zeva Rose 2022-03-20 01:29:16 -06:00
parent 98978dd5b9
commit c64cc86f8d

View file

@ -98,9 +98,15 @@ async def hash(
resp = await session.get(data) resp = await session.get(data)
resp.raise_for_status() resp.raise_for_status()
content_type = resp.content_type content_type = resp.content_type
data_len = resp.content_length
# While we could use resp.content_length, that sometimes returns None,
# so we manually count the size while looping.
data_len = 0
block_count = 0
async for block in resp.content.iter_chunked(n=size): async for block in resp.content.iter_chunked(n=size):
data_len += len(block)
block_count += 1
method.update(block) method.update(block)
return method.hexdigest(), data_len, content_type return method.hexdigest(), data_len, content_type