kdk_handler.py: Add optional check_backups_only property

Reduces false positives for Patcher’s `—cache_os` property, where an installed KDK would match against an expected backup
This commit is contained in:
Mykola Grymalyuk
2023-11-06 09:22:47 -07:00
parent 432736eb98
commit 139f94aae1
+9 -1
View File
@@ -49,7 +49,12 @@ class KernelDebugKitObject:
""" """
def __init__(self, global_constants: constants.Constants, host_build: str, host_version: str, ignore_installed: bool = False, passive: bool = False) -> None: def __init__(self, global_constants: constants.Constants,
host_build: str, host_version: str,
ignore_installed: bool = False, passive: bool = False,
check_backups_only: bool = False
) -> None:
self.constants: constants.Constants = global_constants self.constants: constants.Constants = global_constants
self.host_build: str = host_build # ex. 20A5384c self.host_build: str = host_build # ex. 20A5384c
@@ -58,6 +63,7 @@ class KernelDebugKitObject:
self.passive: bool = passive # Don't perform actions requiring elevated privileges self.passive: bool = passive # Don't perform actions requiring elevated privileges
self.ignore_installed: bool = ignore_installed # If True, will ignore any installed KDKs and download the latest self.ignore_installed: bool = ignore_installed # If True, will ignore any installed KDKs and download the latest
self.check_backups_only: bool = check_backups_only # If True, will only check for KDK backups, not KDKs already installed
self.kdk_already_installed: bool = False self.kdk_already_installed: bool = False
self.kdk_installed_path: str = "" self.kdk_installed_path: str = ""
@@ -400,6 +406,8 @@ class KernelDebugKitObject:
if not Path(KDK_INSTALL_PATH).exists(): if not Path(KDK_INSTALL_PATH).exists():
return None return None
# Installed KDKs only
if self.check_backups_only is False:
for kdk_folder in Path(KDK_INSTALL_PATH).iterdir(): for kdk_folder in Path(KDK_INSTALL_PATH).iterdir():
if not kdk_folder.is_dir(): if not kdk_folder.is_dir():
continue continue