From c64cc86f8d69d559e1a236154c12a0793a0d8ff1 Mon Sep 17 00:00:00 2001 From: zevaryx Date: Sun, 20 Mar 2022 01:29:16 -0600 Subject: [PATCH] Update hash method --- jarvis_core/util/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/jarvis_core/util/__init__.py b/jarvis_core/util/__init__.py index bbef2da..b5feb65 100644 --- a/jarvis_core/util/__init__.py +++ b/jarvis_core/util/__init__.py @@ -98,9 +98,15 @@ async def hash( resp = await session.get(data) resp.raise_for_status() 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): + data_len += len(block) + block_count += 1 method.update(block) return method.hexdigest(), data_len, content_type