diff --git a/.bin/Scripts/functions/common.py b/.bin/Scripts/functions/common.py index a457db16..81b3654e 100644 --- a/.bin/Scripts/functions/common.py +++ b/.bin/Scripts/functions/common.py @@ -173,18 +173,22 @@ def clear_screen(): def convert_to_bytes(size): """Convert human-readable size str to bytes and return an int.""" size = str(size) - tmp = re.search(r'(\d+\.?\d*)\s+([KMGT]B)', size.upper()) + tmp = re.search(r'(\d+\.?\d*)\s+([PTGMKB])B?', size.upper()) if tmp: size = float(tmp.group(1)) units = tmp.group(2) - if units == 'TB': - size *= 1099511627776 - elif units == 'GB': - size *= 1073741824 - elif units == 'MB': - size *= 1048576 - elif units == 'KB': - size *= 1024 + if units == 'P': + size *= 1024 ** 5 + if units == 'T': + size *= 1024 ** 4 + elif units == 'G': + size *= 1024 ** 3 + elif units == 'M': + size *= 1024 ** 2 + elif units == 'K': + size *= 1024 ** 1 + elif units == 'B': + size *= 1024 ** 0 size = int(size) else: return -1