summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJose M. Guisado <jguisado@soleta.eu>2022-07-28 15:19:58 +0200
committerJose M. Guisado <jguisado@soleta.eu>2022-08-22 17:05:12 +0200
commit74a61d6a7d71fa0bfb2a762bad7f754f33f63895 (patch)
treeeec7f917603612dbefadec73f85aecf1ef422e89 /src
parent1b5281c2a1eb9e48d28eee1ad7aef7f5bcc21038 (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/live/ogOperations.py5
1 files changed, 4 insertions, 1 deletions
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)