From 8fb8a0a66dabb5675cc82b37adfd14d00fda6f40 Mon Sep 17 00:00:00 2001 From: OpenGnSys Support Team Date: Thu, 15 Feb 2024 10:45:46 +0100 Subject: fs: return unknown if blkid fails instead of rising an exception --- src/utils/fs.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/utils/fs.py b/src/utils/fs.py index 77f8b75..5bc7956 100644 --- a/src/utils/fs.py +++ b/src/utils/fs.py @@ -97,6 +97,8 @@ def ogReduceFs(disk, part): """ partdev = get_partition_device(disk, part) fstype = get_filesystem_type(partdev) + if fstype == "unknown": + return -1 umount(partdev) if fstype == 'ext4': @@ -117,6 +119,8 @@ def ogExtendFs(disk, part): """ partdev = get_partition_device(disk, part) fstype = get_filesystem_type(partdev) + if fstype == "unknown": + return -1 umount(partdev) if fstype == 'ext4': @@ -198,7 +202,9 @@ def get_filesystem_type(partdev): cmd = shlex.split(f'blkid -o value -s TYPE {partdev}') proc = subprocess.run(cmd, stdout=PIPE, encoding='utf-8') if proc.returncode != 0: - raise RuntimeError(f'Error getting filesystem from {partdev}') + log.error(f'Error getting filesystem from {partdev}') + return "unknown" + return proc.stdout.strip() -- cgit v1.2.3-18-g5258