Skip to content

Commit

Permalink
umu_proton: fix bug when offline and finding latest proton
Browse files Browse the repository at this point in the history
- In the case the user is offline and there exists both a GE-Proton9-10 and GE-Proton9-9, GE-Proton9-9 would be used which may downgrad the prefix if it was created using 9-10. This is because during the max function's comparison, the numeric parts of the strings would not be handled as expected. Moreover, the max function differs from sorted when determining the maximum value when the strings contain numeric parts such that sorted(foo)[0] != max(foo) where foo is an iterable containing string elements with numeric parts appended. To solve this, we need to specify a custom sort routine that handles the numeric parts
  • Loading branch information
R1kaB3rN committed Jul 11, 2024
1 parent 754060a commit 25488c1
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions umu/umu_proton.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from http.client import HTTPException
from json import loads
from pathlib import Path
from re import split as resplit
from shutil import rmtree
from ssl import SSLContext, create_default_context
from tarfile import open as tar_open
Expand Down Expand Up @@ -257,11 +258,17 @@ def _get_from_steamcompat(

try:
latest: Path = max(
proton
for proton in steam_compat.glob("*")
if proton.name.startswith(version)
(
proton
for proton in steam_compat.glob("*")
if proton.name.startswith(version)
),
key=lambda proton: [
int(text) if text.isdigit() else text.lower()
for text in resplit(r"(\d+)", proton.name)
],
)
log.console(f"{latest.name} found in: '{steam_compat}'")
log.console(f"{latest.name} found in '{steam_compat}'")
log.console(f"Using {latest.name}")
os.environ["PROTONPATH"] = str(latest)
env["PROTONPATH"] = os.environ["PROTONPATH"]
Expand Down

0 comments on commit 25488c1

Please sign in to comment.