fs: check if ntfsresize actually succeded to shrink filesystem

According to ntfsresize.c, this retuns 0 in case nothing needs to be done.
It should be safe to check for non-zero error and bail out in that case.
master
OpenGnSys Support Team 2024-02-15 10:37:54 +01:00
parent 0f30b1349d
commit d6c32bba5d
1 changed files with 4 additions and 1 deletions

View File

@ -260,7 +260,10 @@ def _reduce_ntfsresize(partdev):
if new_size < size:
cmd_resize = shlex.split(f'ntfsresize -fs {new_size:.0f} {partdev}')
with open('/tmp/command.log', 'ab', 0) as logfile:
subprocess.run(cmd_resize, input='y', stderr=STDOUT, encoding='utf-8')
proc_resize = subprocess.run(cmd_resize, input='y', stderr=STDOUT, encoding='utf-8')
if proc_resize.returncode != 0:
logging.error(f'ntfsresize on {partdev} with {new_size:.0f} failed with {proc_resize.returncode}')
return -1
return 0