From 74a61d6a7d71fa0bfb2a762bad7f754f33f63895 Mon Sep 17 00:00:00 2001 From: "Jose M. Guisado" Date: Thu, 28 Jul 2022 15:19:58 +0200 Subject: refresh: use '0' if disk has no label If disk has no label, python-libfdisk returns None when accessing cxt.label Fixes bug when running refresh on computers whose disk/s have no label. --- src/live/ogOperations.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/live/ogOperations.py b/src/live/ogOperations.py index a576389..1b2c3dd 100644 --- a/src/live/ogOperations.py +++ b/src/live/ogOperations.py @@ -41,12 +41,15 @@ class OgLiveOperations: def _refresh_payload_disk(self, cxt, part_setup, num_disk): part_setup['disk'] = str(num_disk) part_setup['disk_type'] = 'DISK' - part_setup['code'] = '2' if cxt.label.name == 'gpt' else '1' part_setup['partition'] = '0' part_setup['filesystem'] = '' part_setup['os'] = '' part_setup['size'] = str(cxt.nsectors * cxt.sector_size // 1024) part_setup['used_size'] = '0' + if not cxt.label: + part_setup['code'] = '0' + else: + part_setup['code'] = '2' if cxt.label.name == 'gpt' else '1' def _refresh_payload_partition(self, cxt, pa, part_setup, disk): parttype = cxt.partition_to_string(pa, fdisk.FDISK_FIELD_TYPEID) -- cgit v1.2.3-18-g5258