fs: validate ntfsresize dry-run output

validate 'Needed relocations: ' is in place before stepping on the split chunks

(2024-01-11 10:28:16) ogClient: [ERROR] - Exception when running "image create" subprocess
Traceback (most recent call last):
  File "/opt/opengnsys/ogClient/src/live/ogOperations.py", line 454, in image_create
    ogReduceFs(disk, partition)
  File "/opt/opengnsys/ogClient/src/utils/fs.py", line 105, in ogReduceFs
    _reduce_ntfsresize(partdev)
  File "/opt/opengnsys/ogClient/src/utils/fs.py", line 235, in _reduce_ntfsresize
    extra_size = int(out_resize_dryrun.split('Needed relocations : ')[1].split(' ')[0])*1.1+1024
IndexError: list index out of range

if not present, no need to adjust size
master v1.3.2-5
OpenGnSys Support Team 2024-01-11 12:24:28 +01:00
parent 9beb55894d
commit 5056b8f0d5
1 changed files with 3 additions and 2 deletions

View File

@ -232,8 +232,9 @@ def _reduce_ntfsresize(partdev):
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)
if out_resize_dryrun.find('Needed relocations : ') != -1:
extra_size = int(out_resize_dryrun.split('Needed relocations : ')[1].split(' ')[0])*1.1+1024
new_size += int(extra_size)
if new_size < size:
cmd_resize = shlex.split(f'ntfsresize -fs {new_size:.0f} {partdev}')