diff --git a/snikket_web/infra.py b/snikket_web/infra.py index e31c480..c17f01b 100644 --- a/snikket_web/infra.py +++ b/snikket_web/infra.py @@ -53,7 +53,10 @@ def circle_name(c: typing.Any) -> str: def format_bytes(n: float) -> str: - scale = math.floor(math.log(n, 1024)) + try: + scale = max(math.floor(math.log(n, 1024)), 0) + except ValueError: + scale = 0 try: unit = BYTE_UNIT_SCALE_MAP[scale] factor = 1024**scale