mirror of
https://github.com/KnugiHK/WhatsApp-Chat-Exporter.git
synced 2026-02-10 19:22:24 +00:00
Fix on incorrect rejection by the regex of the size_str
String like '1. MB' should be accepted
This commit is contained in:
@@ -118,10 +118,10 @@ def readable_to_bytes(size_str: str) -> int:
|
||||
'YB': 1024**8
|
||||
}
|
||||
size_str = size_str.upper().strip()
|
||||
match = re.fullmatch(r'^(\d+(\.\d+)?)\s*([KMGTPEZY]?B)?$', size_str)
|
||||
if size_str.isnumeric():
|
||||
# If the string is purely numeric, assume it's in bytes
|
||||
return int(size_str)
|
||||
match = re.fullmatch(r'^(\d+(\.\d*)?)\s*([KMGTPEZY]?B)?$', size_str)
|
||||
if not match:
|
||||
raise ValueError("Invalid size format for size_str. Expected format like '10MB', '1024GB', or '512'.")
|
||||
unit = ''.join(filter(str.isalpha, size_str)).strip()
|
||||
|
||||
Reference in New Issue
Block a user