def size_to_bytes(size_str): if not size_str: return 0 parts = size_str.strip().split() if len(parts) != 2: return 0 value, unit = float(parts[0]), parts[1].upper() multipliers = { "B": 1, "KB": 1024, "MB": 1024**2, "GB": 1024**3, "TB": 1024**4, } return int(value * multipliers.get(unit, 1))