Avoid potential crash in run_chkdsk_online()
This commit is contained in:
parent
7064472e0b
commit
9351b597c2
1 changed files with 14 additions and 4 deletions
|
|
@ -338,16 +338,26 @@ def run_chkdsk_online():
|
||||||
|
|
||||||
# Run scan
|
# Run scan
|
||||||
run_program(cmd, check=False)
|
run_program(cmd, check=False)
|
||||||
proc = get_procs('chkdsk.exe')[0]
|
try:
|
||||||
return_code = proc.wait()
|
proc = get_procs('chkdsk.exe')[0]
|
||||||
|
return_code = proc.wait()
|
||||||
|
except IndexError:
|
||||||
|
# Failed to get CHKDSK process, set return_code to force a retry
|
||||||
|
return_code = 255
|
||||||
if return_code > 1:
|
if return_code > 1:
|
||||||
# Try again
|
# Try again
|
||||||
retried = True
|
retried = True
|
||||||
run_program(cmd, check=False)
|
run_program(cmd, check=False)
|
||||||
proc = get_procs('chkdsk.exe')[0]
|
try:
|
||||||
return_code = proc.wait()
|
proc = get_procs('chkdsk.exe')[0]
|
||||||
|
return_code = proc.wait()
|
||||||
|
except IndexError:
|
||||||
|
# Failed to get CHKDSK process
|
||||||
|
return_code = -1
|
||||||
|
|
||||||
# Check result
|
# Check result
|
||||||
|
if return_code == -1:
|
||||||
|
raise GenericError('Failed to find CHKDSK process.')
|
||||||
if (return_code == 0 and retried) or return_code == 1:
|
if (return_code == 0 and retried) or return_code == 1:
|
||||||
raise GenericWarning('Repaired (or manually aborted)')
|
raise GenericWarning('Repaired (or manually aborted)')
|
||||||
if return_code > 1:
|
if return_code > 1:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue