From ea6e72bf0b3acd4e846c778592432fbe3acd11a6 Mon Sep 17 00:00:00 2001 From: KnugiHK <24708955+KnugiHK@users.noreply.github.com> Date: Sat, 17 May 2025 17:46:51 +0800 Subject: [PATCH] Bug fix on incorrectly striping decimal to integer --- Whatsapp_Chat_Exporter/utility.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Whatsapp_Chat_Exporter/utility.py b/Whatsapp_Chat_Exporter/utility.py index 75744bb..2053133 100644 --- a/Whatsapp_Chat_Exporter/utility.py +++ b/Whatsapp_Chat_Exporter/utility.py @@ -118,10 +118,11 @@ def readable_to_bytes(size_str: str) -> int: 'YB': 1024**8 } size_str = size_str.upper().strip() - number, unit = size_str[:-2].strip(), size_str[-2:].strip() - if unit not in SIZE_UNITS or not number.isnumeric(): + unit = ''.join(filter(str.isalpha, size_str)).strip() + number = ''.join(c for c in size_str if c.isdigit() or c == '.').strip() + if unit not in SIZE_UNITS: raise ValueError("Invalid input for size_str. Example: 1024GB") - return int(number) * SIZE_UNITS[unit] + return int(float(number) * SIZE_UNITS[unit]) def sanitize_except(html: str) -> Markup: