Skip to content

Commit a63e8ae

Browse files
authored
Torxed issue 1083 (#1090)
* Optimized a bunch of partprobe calls. Namely fixed sleep calls, added optional path to the general archinstall.partprobe() call. And fixed some error handling in a few places which should tell us where #1083 might be going wrong. * Fixed some flake8 complaints * Fixed sleep having a min() of 0.1 or given value. * Fixed sleep having a correct range variable. * Fixed sleep logic to use max() instead of min() as it will never use the higer sleep values otheride * Added error handling to Partition().partprobe() as it would cause certain issues with USB disks. Also made Partition()._safe_uuid more safe by eliminating exceptions being raised.
1 parent 59c35df commit a63e8ae

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

archinstall/lib/disk/partition.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,9 @@ def uuid(self) -> Optional[str]:
192192
For bind mounts all the subvolumes share the same uuid
193193
"""
194194
for i in range(storage['DISK_RETRY_ATTEMPTS']):
195-
self.partprobe()
195+
if not self.partprobe():
196+
raise DiskError(f"Could not perform partprobe on {self.device_path}")
197+
196198
time.sleep(max(0.1, storage['DISK_TIMEOUTS'] * i))
197199

198200
partuuid = self._safe_uuid
@@ -208,13 +210,11 @@ def _safe_uuid(self) -> Optional[str]:
208210
This function should only be used where uuid is not crucial.
209211
For instance when you want to get a __repr__ of the class.
210212
"""
211-
try:
212-
self.partprobe()
213-
except SysCallError as partprobe_error:
213+
if not self.partprobe():
214214
if self.block_device.info.get('TYPE') == 'iso9660':
215215
return None
216216

217-
raise DiskError(f"Could not get PARTUUID of partition {self} due to partprobe error: {partprobe_error}")
217+
log(f"Could not reliably refresh PARTUUID of partition {self.device_path} due to partprobe error.", level=logging.DEBUG)
218218

219219
try:
220220
return SysCommand(f'blkid -s PARTUUID -o value {self.device_path}').decode('UTF-8').strip()
@@ -223,7 +223,7 @@ def _safe_uuid(self) -> Optional[str]:
223223
# Parent device is a Optical Disk (.iso dd'ed onto a device for instance)
224224
return None
225225

226-
raise DiskError(f"Could not get PARTUUID of partition {self}: {error}")
226+
log(f"Could not get PARTUUID of partition using 'blkid -s PARTUUID -o value {self.device_path}': {error}")
227227

228228
@property
229229
def encrypted(self) -> Union[bool, None]:
@@ -267,8 +267,12 @@ def subvolumes(self) -> Iterator[BtrfsSubvolume]:
267267
yield result
268268

269269
def partprobe(self) -> bool:
270-
if self.block_device and SysCommand(f'partprobe {self.block_device.device}').exit_code == 0:
271-
return True
270+
try:
271+
if self.block_device:
272+
return 0 == SysCommand(f'partprobe {self.block_device.device}').exit_code
273+
except SysCallError as error:
274+
log(f"Unreliable results might be given for {self.path} due to partprobe error: {error}", level=logging.DEBUG)
275+
272276
return False
273277

274278
def detect_inner_filesystem(self, password :str) -> Optional[str]:

0 commit comments

Comments
 (0)