Skip to content

Commit

Permalink
Merge pull request #221 from vojtechtrefny/master_unknown-filesystems
Browse files Browse the repository at this point in the history
Improve handling of formats not supported by Blivet
  • Loading branch information
vojtechtrefny committed Aug 3, 2020
2 parents c43708e + dcb5418 commit e52742b
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
5 changes: 2 additions & 3 deletions blivetgui/blivet_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ def delete_device(self, blivet_device, delete_parents):
return result

try:
if blivet_device.format.type and not blivet_device.format_immutable:
if not blivet_device.format_immutable:
ac_fmt = blivet.deviceaction.ActionDestroyFormat(blivet_device)
self.storage.devicetree.actions.add(ac_fmt)
actions.append(ac_fmt)
Expand Down Expand Up @@ -707,8 +707,7 @@ def format_device(self, user_input):

fmt_actions = []

if user_input.edit_device.format.type is not None:
fmt_actions.append(blivet.deviceaction.ActionDestroyFormat(user_input.edit_device))
fmt_actions.append(blivet.deviceaction.ActionDestroyFormat(user_input.edit_device))

if user_input.filesystem:
fmt_actions.extend(self._create_format(user_input, user_input.edit_device))
Expand Down
11 changes: 10 additions & 1 deletion blivetgui/list_partitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,16 @@ def _add_to_store(self, device, parent_iter=None):
"""

devtype = "lvm" if device.type == "lvmvg" else "raid" if device.type == "mdarray" else device.type
fmt = device.format.type if device.format else None

if device.format.type:
fmt = device.format.type
else:
if device.format.name != "Unknown":
# format recognized by blkid but not supported by blivet
fmt = device.format.name
else:
fmt = None

if self.installer_mode:
mnt = device.format.mountpoint if (device.format and device.format.mountable) else None
else:
Expand Down
13 changes: 12 additions & 1 deletion tests/blivetgui_tests/list_partitions_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,20 @@ def test_add_to_store(self):
self.assertEqual(self.list_partitions.partitions_list.get_value(it, 1), device.name)
self.assertEqual(self.list_partitions.partitions_list.get_value(it, 6), ", ".join(mountpoints))

# partition with unknown/unsupported filesystem
fmt = MagicMock(type=None, mountable=False, label=None)
fmt.configure_mock(name="exfat")
device = MagicMock(type="partition", size=Size("1 GiB"), path="/dev/vda1",
format=fmt)
device.configure_mock(name="vda1")
it = self.list_partitions._add_to_store(device)
self.assertEqual(self.list_partitions.partitions_list.get_value(it, 3), device.format.name)

# lvmvg with long name -- name should be elipsized and type should be 'lvm'
fmt = MagicMock(type=None, mountable=False, label=None)
fmt.configure_mock(name="Unknown")
device = MagicMock(type="lvmvg", size=Size("1 GiB"),
format=MagicMock(type=None, mountable=False, label=None))
format=fmt)
device.configure_mock(name="".join(["a" for i in range(20)]))

it = self.list_partitions._add_to_store(device)
Expand Down
11 changes: 8 additions & 3 deletions tests/blivetutils_tests/test_10_disks.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,18 @@ def test_30_raw_format(self):
actions = self.format_device(device=blivet_disk, fstype=fs)

# check scheduled actions
self.assertEqual(len(actions), 1)
self.assertIsInstance(actions[0], blivet.deviceaction.ActionCreateFormat)
self.assertEqual(len(actions), 2)
self.assertIsInstance(actions[0], blivet.deviceaction.ActionDestroyFormat)
self.assertIsInstance(actions[1], blivet.deviceaction.ActionCreateFormat)

self.assertEqual(actions[0].device, blivet_disk)
self.assertTrue(actions[0].is_create)
self.assertTrue(actions[0].is_destroy)
self.assertTrue(actions[0].is_format)

self.assertEqual(actions[1].device, blivet_disk)
self.assertTrue(actions[1].is_create)
self.assertTrue(actions[1].is_format)

# check that the device has been changed
blivet_disk = self.get_blivet_device(self.vdevs[0])
self.assertEqual(blivet_disk.format.type, fs)
Expand Down

0 comments on commit e52742b

Please sign in to comment.