Fix partition table commit (#2294)

This commit is contained in:
codefiles 2024-03-07 07:49:14 -05:00 committed by GitHub
parent 1bf68311c2
commit b39e3dc886
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 10 deletions

View File

@ -322,7 +322,7 @@ class DeviceHandler(object):
part_mod.partuuid = lsblk_info.partuuid
part_mod.uuid = lsblk_info.uuid
def _perform_partitioning(
def _setup_partition(
self,
part_mod: PartitionModification,
block_device: BDevice,
@ -339,7 +339,6 @@ class DeviceHandler(object):
raise DiskError(f'No partition for dev path found: {part_mod.safe_dev_path}')
disk.deletePartition(part_info.partition)
disk.commit()
if part_mod.status == ModificationStatus.Delete:
return
@ -378,16 +377,12 @@ class DeviceHandler(object):
try:
disk.addPartition(partition=partition, constraint=disk.device.optimalAlignedConstraint)
disk.commit()
# the creation will take a bit of time
time.sleep(3)
# the partition has a real path now as it was created
part_mod.dev_path = Path(partition.path)
except PartitionException as ex:
raise DiskError(f'Unable to add partition, most likely due to overlapping sectors: {ex}') from ex
# the partition has a path now that it has been added
part_mod.dev_path = Path(partition.path)
def _fetch_part_info(self, path: Path) -> LsblkInfo:
attempts = 3
lsblk_info: Optional[LsblkInfo] = None
@ -535,7 +530,9 @@ class DeviceHandler(object):
# if the entire disk got nuked then we don't have to delete
# any existing partitions anymore because they're all gone already
requires_delete = modification.wipe is False
self._perform_partitioning(part_mod, modification.device, disk, requires_delete=requires_delete)
self._setup_partition(part_mod, modification.device, disk, requires_delete=requires_delete)
disk.commit()
def mount(
self,