You've already forked snikket-web-portal
Handle the correct exception when formatting extremely high amounts of bytes
Found in production. Yes really. Due to some borked LXC integration, my snikket host reports ``` MemTotal: 9007199254740991 kB MemFree: 9007199254690591 kB MemAvailable: 9007199254690591 kB ``` That is more than 1024 TiB, so it tries to go further up in the scale, which then causes a Guru Meditation because of the uncaught IndexError.
This commit is contained in:
@@ -60,7 +60,7 @@ def format_bytes(n: float) -> str:
|
||||
try:
|
||||
unit = BYTE_UNIT_SCALE_MAP[scale]
|
||||
factor = 1024**scale
|
||||
except ValueError:
|
||||
except IndexError:
|
||||
unit = "TiB"
|
||||
factor = 1024**4
|
||||
if factor > 1:
|
||||
|
||||
Reference in New Issue
Block a user