Fix possible crash in reset_windows_updates()
Auto Repairs could end up in an endless boot loop if SoftwareDistribution.old exists before running
This commit is contained in:
parent
8a685d4e60
commit
bf6482a594
1 changed files with 10 additions and 6 deletions
|
|
@ -19,7 +19,12 @@ from wk.exe import (
|
||||||
popen_program,
|
popen_program,
|
||||||
wait_for_procs,
|
wait_for_procs,
|
||||||
)
|
)
|
||||||
from wk.io import delete_folder, get_path_obj, rename_item
|
from wk.io import (
|
||||||
|
delete_folder,
|
||||||
|
get_path_obj,
|
||||||
|
non_clobber_path,
|
||||||
|
rename_item,
|
||||||
|
)
|
||||||
from wk.kit.tools import download_tool, get_tool_path, run_tool
|
from wk.kit.tools import download_tool, get_tool_path, run_tool
|
||||||
from wk.log import format_log_path, update_log_path
|
from wk.log import format_log_path, update_log_path
|
||||||
from wk.os.win import (
|
from wk.os.win import (
|
||||||
|
|
@ -1229,12 +1234,11 @@ def reset_windows_policies():
|
||||||
def reset_windows_updates():
|
def reset_windows_updates():
|
||||||
"""Reset Windows Updates."""
|
"""Reset Windows Updates."""
|
||||||
system_root = os.environ.get('SYSTEMROOT', 'C:/Windows')
|
system_root = os.environ.get('SYSTEMROOT', 'C:/Windows')
|
||||||
|
src_path = f'{system_root}/SoftwareDistribution'
|
||||||
|
dest_path = non_clobber_path(f'{src_path}.old')
|
||||||
try:
|
try:
|
||||||
rename_item(
|
rename_item(src_path, dest_path)
|
||||||
f'{system_root}/SoftwareDistribution',
|
delete_folder(dest_path, force=True)
|
||||||
f'{system_root}/SoftwareDistribution.old',
|
|
||||||
)
|
|
||||||
delete_folder(f'{system_root}/SoftwareDistribution.old', force=True)
|
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
# Ignore
|
# Ignore
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue