mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-06-20 22:20:53 +10:00
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:
+20
-12
@@ -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
|
||||||
@@ -57,7 +62,8 @@ 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,18 +406,20 @@ class KernelDebugKitObject:
|
|||||||
if not Path(KDK_INSTALL_PATH).exists():
|
if not Path(KDK_INSTALL_PATH).exists():
|
||||||
return None
|
return None
|
||||||
|
|
||||||
for kdk_folder in Path(KDK_INSTALL_PATH).iterdir():
|
# Installed KDKs only
|
||||||
if not kdk_folder.is_dir():
|
if self.check_backups_only is False:
|
||||||
continue
|
for kdk_folder in Path(KDK_INSTALL_PATH).iterdir():
|
||||||
if check_version:
|
if not kdk_folder.is_dir():
|
||||||
if match not in kdk_folder.name:
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
if not kdk_folder.name.endswith(f"{match}.kdk"):
|
|
||||||
continue
|
continue
|
||||||
|
if check_version:
|
||||||
|
if match not in kdk_folder.name:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
if not kdk_folder.name.endswith(f"{match}.kdk"):
|
||||||
|
continue
|
||||||
|
|
||||||
if self._local_kdk_valid(kdk_folder):
|
if self._local_kdk_valid(kdk_folder):
|
||||||
return kdk_folder
|
return kdk_folder
|
||||||
|
|
||||||
# If we can't find a KDK, next check if there's a backup present
|
# If we can't find a KDK, next check if there's a backup present
|
||||||
# Check for KDK packages in the same directory as the KDK
|
# Check for KDK packages in the same directory as the KDK
|
||||||
|
|||||||
Reference in New Issue
Block a user