mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-07-08 11:40:25 +00:00
storage: Handle mount error properly
Closes: #2343. - The change is needed due to change in privileged exception handling. Tests: - In vagrant machine, while FreedomBox service is running, run unit tests are root user. Observe that exception is not handled properly without the patch. But a more reasonable error is printed with the patch. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
e525d0ff72
commit
43a2734917
@ -196,14 +196,14 @@ def _mount(object_path):
|
||||
try:
|
||||
privileged.mount(block_device.preferred_device, _log_error=False)
|
||||
except Exception as exception:
|
||||
parts = exception.args[2].split(':')
|
||||
if parts[1].strip() != 'GDBus.Error':
|
||||
stderr = exception.args[3].decode()
|
||||
if 'GDBus.Error' not in stderr:
|
||||
raise
|
||||
|
||||
if parts[2].strip() == _ERRORS['AlreadyMounted']:
|
||||
if _ERRORS['AlreadyMounted'] in stderr:
|
||||
logger.warning('Device is already mounted: %s %s', block_device.id,
|
||||
block_device.preferred_device)
|
||||
elif parts[2].strip() == _ERRORS['Failed']:
|
||||
elif _ERRORS['Failed'] in stderr:
|
||||
logger.warning('Mount operation failed: %s %s: %s',
|
||||
block_device.id, block_device.preferred_device,
|
||||
exception)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user