From abea6583d3d9cef9b1187e9fcfdfc1bb4bfcce25 Mon Sep 17 00:00:00 2001 From: Alejandro Sirgo Rica Date: Tue, 7 May 2024 16:42:55 +0200 Subject: 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. --- src/utils/fs.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils/fs.py b/src/utils/fs.py index 184b47a..766c09b 100644 --- a/src/utils/fs.py +++ b/src/utils/fs.py @@ -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) -- cgit v1.2.3-18-g5258