From 88668cb19534c9b7becf479370e8faee4c78ed39 Mon Sep 17 00:00:00 2001 From: "Jose M. Guisado" Date: Tue, 13 Jun 2023 17:24:40 +0200 Subject: fs: fix bug when ntfsresize reports nothing to do There is a corner case in which a target NTFS filesystem is already shrunken. When this happens ntfsresize text output parsing breaks. Check when ntfsresize reports nothing to do, warn the user about this and stop the dry-run ntfsresize loop. --- src/utils/fs.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/utils/fs.py b/src/utils/fs.py index a025873..4d54586 100644 --- a/src/utils/fs.py +++ b/src/utils/fs.py @@ -229,6 +229,9 @@ def _reduce_ntfsresize(partdev): proc_resize_dryrun = subprocess.run(cmd_resize_dryrun, stdout=subprocess.PIPE, encoding='utf-8') returncode = proc_resize_dryrun.returncode out_resize_dryrun = proc_resize_dryrun.stdout.strip() + if 'Nothing to do: NTFS volume size is already OK.' in out_resize_dryrun: + logging.warn('ntfsresize reports nothing to do. Is the target filesystem already shrunken?') + break extra_size = int(out_resize_dryrun.split('Needed relocations : ')[1].split(' ')[0])*1.1+1024 new_size += int(extra_size) -- cgit v1.2.3-18-g5258