utils: add mkdir error report in mount_mkdir

Add exception checks to the os.mkdir operation and log the error
found. The previous implementation was too optimistic and only
handled mount related errors.
master
Alejandro Sirgo Rica 2024-05-07 16:42:55 +02:00
parent 493d998a4e
commit abea6583d3
1 changed files with 5 additions and 1 deletions

View File

@ -36,7 +36,11 @@ def mount_mkdir(source, target):
Return True if mount is sucessful or if target is already a mountpoint.
"""
if not os.path.exists(target):
os.mkdir(target)
try:
os.mkdir(target)
except OSError as e:
logging.error(f'mkdir operation failed. Reported {e}')
return False
if not os.path.ismount(target):
return mount(source, target)