Merge pull request #734 from archlinux/torxed-fix-luks

Error handling when PARTUUID is missing during __repr__
This commit is contained in:
Anton Hvornum 2021-11-18 15:26:06 +00:00 committed by GitHub
commit 37c84e1781
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 4 deletions

View File

@ -64,10 +64,14 @@ class Partition:
elif self.target_mountpoint:
mount_repr = f", rel_mountpoint={self.target_mountpoint}"
if self._encrypted:
return f'Partition(path={self.path}, size={self.size}, PARTUUID={self.uuid}, parent={self.real_device}, fs={self.filesystem}{mount_repr})'
else:
return f'Partition(path={self.path}, size={self.size}, PARTUUID={self.uuid}, fs={self.filesystem}{mount_repr})'
try:
if self._encrypted:
return f'Partition(path={self.path}, size={self.size}, PARTUUID={self.uuid}, parent={self.real_device}, fs={self.filesystem}{mount_repr})'
else:
return f'Partition(path={self.path}, size={self.size}, PARTUUID={self.uuid}, fs={self.filesystem}{mount_repr})'
except DiskError:
# DiskErrors occur when we cannot retrieve the UUID of the partition, usually due to encryption or a slow disk.
return f'Partition(path={self.path}, size={self.size}, PARTUUID=None, fs={self.filesystem}{mount_repr})'
def __dump__(self):
return {