small hacks to only allow one prep partition at a time

This commit is contained in:
Michael Hudson-Doyle 2020-04-21 11:48:02 +12:00
parent 5524197837
commit 69775133cf
3 changed files with 10 additions and 9 deletions

View File

@ -679,6 +679,10 @@ class FilesystemController(SubiquityController):
def add_boot_disk(self, new_boot_disk):
bootloader = self.model.bootloader
if bootloader == Bootloader.PREP:
for disk in self.model.all_disks():
if disk._is_boot_device():
self.remove_boot_disk(disk)
if new_boot_disk._has_preexisting_partition():
if bootloader == Bootloader.BIOS:
new_boot_disk.grub_device = True

View File

@ -215,7 +215,7 @@ class TestFilesystemController(unittest.TestCase):
size_before = disk2p1.size
controller.add_boot_disk(disk2)
self.assertEqual(len(disk1.partitions()), 1)
self.assertEqual(len(disk1.partitions()), 0)
self.assertEqual(len(disk2.partitions()), 2)
self.assertEqual(disk2.partitions()[1], disk2p1)
self.assertEqual(
@ -223,11 +223,6 @@ class TestFilesystemController(unittest.TestCase):
self.assertEqual(disk2.partitions()[0].flag, "prep")
self.assertEqual(disk2.partitions()[0].wipe, "zero")
controller.remove_boot_disk(disk2)
self.assertEqual(len(disk2.partitions()), 1)
self.assertEqual(disk2.partitions()[0], disk2p1)
self.assertEqual(disk2p1.size, size_before)
def test_make_boot_disk_PREP_existing(self):
controller = make_controller(Bootloader.PREP)
disk1 = make_disk(controller.model, preserve=True)

View File

@ -61,6 +61,7 @@ from subiquitycore.ui.utils import (
from subiquitycore.view import BaseView
from subiquity.models.filesystem import (
Bootloader,
DeviceAction,
humanize_size,
)
@ -329,6 +330,7 @@ class DeviceList(WidgetWrap):
if device._is_boot_device():
return _("Stop Using As Boot Device")
else:
if self.parent.model.bootloader != Bootloader.PREP:
for other in self.parent.model.all_disks():
if other._is_boot_device():
return _("Add As Another Boot Device")