mirror of
https://github.com/tcsenpai/UWINE.git
synced 2025-06-06 19:45:20 +00:00
ulwgl_dl_util: move download to func
This commit is contained in:
parent
e3563cb8f3
commit
4691e26f23
@ -38,25 +38,10 @@ def get_ulwgl_proton(env: Dict[str, str]) -> Union[Dict[str, str], None]:
|
||||
if _get_from_cache(env, steam_compat, cache, files, True):
|
||||
return env
|
||||
|
||||
# Download the latest if GE-Proton is not in Steam compat
|
||||
# Download the latest if Proton is not in Steam compat
|
||||
# If the digests mismatched, refer to the cache in the next block
|
||||
if files:
|
||||
print("Fetching latest release ...")
|
||||
try:
|
||||
_fetch_proton(env, steam_compat, cache, files)
|
||||
env["PROTONPATH"] = environ["PROTONPATH"]
|
||||
|
||||
if _get_latest(env, steam_compat, cache, files):
|
||||
return env
|
||||
except ValueError:
|
||||
# Digest mismatched branch
|
||||
# In this case, just leave it up to the user to handle it
|
||||
pass
|
||||
except KeyboardInterrupt:
|
||||
# Exit cleanly
|
||||
# Clean up incompleted files/dir
|
||||
_cleanup(
|
||||
files[1][0], files[1][0][: files[1][0].find(".")], cache, steam_compat
|
||||
)
|
||||
|
||||
# Cache
|
||||
# Refer to an old version previously installed
|
||||
@ -260,3 +245,31 @@ def _get_from_cache(
|
||||
raise
|
||||
|
||||
return env
|
||||
|
||||
|
||||
def _get_latest(
|
||||
env: Dict[str, str], steam_compat: Path, cache: Path, files: List[Tuple[str, str]]
|
||||
) -> Dict[str, str]:
|
||||
"""Download the latest Proton for new installs -- empty cache and Steam compat.
|
||||
|
||||
When the digests mismatched or when interrupted, refer to cache for an old version
|
||||
"""
|
||||
if files:
|
||||
tarball: str = files[1][0]
|
||||
|
||||
print("Fetching latest release ...")
|
||||
try:
|
||||
_fetch_proton(env, steam_compat, cache, files)
|
||||
env["PROTONPATH"] = environ["PROTONPATH"]
|
||||
except ValueError:
|
||||
# Digest mismatched or download failed
|
||||
# Refer to the cache for old version next
|
||||
return None
|
||||
except KeyboardInterrupt:
|
||||
# Exit cleanly
|
||||
# Clean up extracted data and cache to prevent corruption/errors
|
||||
# Refer to the cache for old version next
|
||||
_cleanup(tarball, tarball[: tarball.find(".")], cache, steam_compat)
|
||||
return None
|
||||
|
||||
return env
|
||||
|
Loading…
x
Reference in New Issue
Block a user