Fix partition creation size end (#2858)

This commit is contained in:
codefiles 2024-11-17 17:04:12 -05:00 committed by GitHub
parent 8fc3dc4358
commit 6ca80d1fd7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 18 additions and 13 deletions

View File

@ -236,23 +236,28 @@ class PartitioningList(ListManager):
) -> Size | None:
match = re.match(r'([0-9]+)([a-zA-Z|%]*)', text, re.I)
if match:
str_value, unit = match.groups()
if not match:
return None
if unit == '%' and start:
available = total_size - start
value = int(available.value * (int(str_value) / 100))
unit = available.unit.name
else:
value = int(str_value)
str_value, unit = match.groups()
if unit and unit not in Unit.get_all_units():
return None
if unit == '%' and start:
available = total_size - start
value = int(available.value * (int(str_value) / 100))
unit = available.unit.name
else:
value = int(str_value)
unit = Unit[unit] if unit else Unit.sectors
return Size(value, unit, sector_size)
if unit and unit not in Unit.get_all_units():
return None
return None
unit = Unit[unit] if unit else Unit.sectors
size = Size(value, unit, sector_size)
if start and size <= start:
return None
return size
def _enter_size(
self,