filesystem: no guided UseGap when disk is empty

This commit is contained in:
Dan Bungert 2022-07-05 14:15:16 -06:00
parent be805ffb36
commit be4cd23ffe
2 changed files with 6 additions and 5 deletions

View File

@ -405,6 +405,10 @@ class FilesystemController(SubiquityController, FilesystemManipulator):
scenarios.append((disk.size, reformat))
for disk in self.get_guided_disks(with_reformatting=False):
if len(disk.partitions()) < 1:
# On an empty disk, don't bother to offer it with UseGap, as
# it's basically the same as the Reformat case.
continue
gap = gaps.largest_gap(disk)
if gap is not None and gap.size >= install_min:
api_gap = labels.for_client(gap)

View File

@ -159,13 +159,10 @@ class TestGuidedV2(IsolatedAsyncioTestCase):
@parameterized.expand(bootloaders)
async def test_blank_disk(self, bootloader):
# blank disks should not report a UseGap case
self._setup(bootloader)
d = make_disk(self.model, size=(30 << 30) + (2 << 20))
gap = types.Gap(offset=1 << 20, size=30 << 30)
expected = [
GuidedStorageTargetReformat(disk_id=d.id),
GuidedStorageTargetUseGap(disk_id=d.id, gap=gap),
]
expected = [GuidedStorageTargetReformat(disk_id=d.id)]
resp = await self.fsc.v2_guided_GET()
self.assertEqual(expected, resp.possible)