diff options
author | Jose M. Guisado <jguisado@soleta.eu> | 2023-06-13 17:24:40 +0200 |
---|---|---|
committer | Jose M. Guisado <jguisado@soleta.eu> | 2023-06-13 17:34:04 +0200 |
commit | 88668cb19534c9b7becf479370e8faee4c78ed39 (patch) | |
tree | ccb04901c9dbe3ed2e125b0aeb99edb06682cebe /src | |
parent | 666d2fb50f89d51642ac9e74c18f9ccc4ef28985 (diff) |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/utils/fs.py | 3 |
1 files changed, 3 insertions, 0 deletions
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) |