refuse to add a boot partition if it means shrinking a partition by more than 50%
This commit is contained in:
parent
fd0a7954e4
commit
58d9670372
|
@ -208,6 +208,8 @@ def get_add_part_plan(device, *, spec, args):
|
|||
largest_i, largest_part = max(
|
||||
enumerate(partitions),
|
||||
key=lambda i_p: i_p[1].size)
|
||||
if size > largest_part.size // 2:
|
||||
return None
|
||||
create_part_plan.offset = largest_part.offset
|
||||
return MultiStepPlan(plans=[
|
||||
SlidePlan(
|
||||
|
|
|
@ -279,9 +279,9 @@ class TestFilesystemManipulator(unittest.TestCase):
|
|||
|
||||
def test_add_boot_BIOS_full_resizes_larger(self):
|
||||
manipulator = make_manipulator(Bootloader.BIOS)
|
||||
# 402MiB so that the space available for partitioning (400MiB)
|
||||
# 2002MiB so that the space available for partitioning (2000MiB)
|
||||
# divided by 4 is an whole number of megabytes.
|
||||
disk = make_disk(manipulator.model, preserve=True, size=402*MiB)
|
||||
disk = make_disk(manipulator.model, preserve=True, size=2002*MiB)
|
||||
part_smaller = make_partition(
|
||||
manipulator.model, disk, size=gaps.largest_gap_size(disk)//4)
|
||||
part_larger = make_partition(
|
||||
|
@ -354,9 +354,9 @@ class TestFilesystemManipulator(unittest.TestCase):
|
|||
|
||||
def test_add_boot_UEFI_full_resizes_larger(self):
|
||||
manipulator = make_manipulator(Bootloader.UEFI)
|
||||
# 402MiB so that the space available for partitioning (400MiB)
|
||||
# 2002MiB so that the space available for partitioning (2000MiB)
|
||||
# divided by 4 is an whole number of megabytes.
|
||||
disk = make_disk(manipulator.model, preserve=True, size=402*MiB)
|
||||
disk = make_disk(manipulator.model, preserve=True, size=2002*MiB)
|
||||
part_smaller = make_partition(
|
||||
manipulator.model, disk, size=gaps.largest_gap_size(disk)//4)
|
||||
part_larger = make_partition(
|
||||
|
|
Loading…
Reference in New Issue