ulwgl_dl_util: move steamcompat to func

This commit is contained in:
R1kaB3rN 2024-02-16 11:32:08 -08:00
parent 08d18203f8
commit f64b473157
No known key found for this signature in database

View File

@ -31,18 +31,7 @@ def get_ulwgl_proton(env: Dict[str, str]) -> Union[Dict[str, str], None]:
steam_compat.mkdir(exist_ok=True, parents=True)
# Prioritize the Steam compat
for proton in steam_compat.glob("GE-Proton*"):
print(f"{proton.name} found in: {steam_compat.as_posix()}")
environ["PROTONPATH"] = proton.as_posix()
env["PROTONPATH"] = environ["PROTONPATH"]
# Notify the user that they're not using the latest
if len(files) == 2 and proton.name != files[1][0][: files[1][0].find(".")]:
print(
"GE-Proton is outdated and requires manual intervention.\nFor latest release, please download "
+ files[1][0]
)
if _get_from_steamcompat(env, steam_compat, cache, files):
return env
# Check if the latest isn't already in the cache
@ -230,3 +219,24 @@ def _cleanup(tarball, proton, cache, steam_compat) -> None:
if steam_compat.joinpath(proton).is_dir():
print(f"Purging {proton} in {steam_compat} ...")
rmtree(steam_compat.joinpath(proton).as_posix())
def _get_from_steamcompat(
env: Dict[str, str], steam_compat: Path, cache: Path, files: List[Tuple[str, str]]
) -> Dict[str, str]:
"""Refer to Steam compat folder for any existing Proton directories."""
for proton in steam_compat.glob("GE-Proton*"):
print(f"{proton.name} found in: {steam_compat.as_posix()}")
environ["PROTONPATH"] = proton.as_posix()
env["PROTONPATH"] = environ["PROTONPATH"]
# Notify the user that they're not using the latest
if len(files) == 2 and proton.name != files[1][0][: files[1][0].find(".")]:
print(
"GE-Proton is outdated and requires manual intervention.\nFor latest release, please download "
+ files[1][1]
)
return env
return None