Fix partition table commit (#2294)
This commit is contained in:
parent
1bf68311c2
commit
b39e3dc886
|
|
@ -322,7 +322,7 @@ class DeviceHandler(object):
|
||||||
part_mod.partuuid = lsblk_info.partuuid
|
part_mod.partuuid = lsblk_info.partuuid
|
||||||
part_mod.uuid = lsblk_info.uuid
|
part_mod.uuid = lsblk_info.uuid
|
||||||
|
|
||||||
def _perform_partitioning(
|
def _setup_partition(
|
||||||
self,
|
self,
|
||||||
part_mod: PartitionModification,
|
part_mod: PartitionModification,
|
||||||
block_device: BDevice,
|
block_device: BDevice,
|
||||||
|
|
@ -339,7 +339,6 @@ class DeviceHandler(object):
|
||||||
raise DiskError(f'No partition for dev path found: {part_mod.safe_dev_path}')
|
raise DiskError(f'No partition for dev path found: {part_mod.safe_dev_path}')
|
||||||
|
|
||||||
disk.deletePartition(part_info.partition)
|
disk.deletePartition(part_info.partition)
|
||||||
disk.commit()
|
|
||||||
|
|
||||||
if part_mod.status == ModificationStatus.Delete:
|
if part_mod.status == ModificationStatus.Delete:
|
||||||
return
|
return
|
||||||
|
|
@ -378,16 +377,12 @@ class DeviceHandler(object):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
disk.addPartition(partition=partition, constraint=disk.device.optimalAlignedConstraint)
|
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:
|
except PartitionException as ex:
|
||||||
raise DiskError(f'Unable to add partition, most likely due to overlapping sectors: {ex}') from 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:
|
def _fetch_part_info(self, path: Path) -> LsblkInfo:
|
||||||
attempts = 3
|
attempts = 3
|
||||||
lsblk_info: Optional[LsblkInfo] = None
|
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
|
# if the entire disk got nuked then we don't have to delete
|
||||||
# any existing partitions anymore because they're all gone already
|
# any existing partitions anymore because they're all gone already
|
||||||
requires_delete = modification.wipe is False
|
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(
|
def mount(
|
||||||
self,
|
self,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue