Merge pull request #5423 from CKolle/bug_fix_proton_env

Fix NoneType error in get_game_id function
This commit is contained in:
Daniel Johnson 2024-04-13 17:27:44 -04:00 committed by GitHub
commit 051908f686
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -100,14 +100,22 @@ def get_proton_path_from_bin(wine_path):
def get_game_id(game) -> str:
games_path = os.path.join(settings.RUNTIME_DIR, "umu-games/umu-games.json")
env = game.runner.get_env()
if game and env.get("GAMEID") or env.get("UMU_ID"):
return env.get("GAMEID") or env.get("UMU_ID")
if not os.path.exists(games_path) or not game:
if not game:
return DEFAULT_GAMEID
envs = game.runner.get_env()
game_id = envs.get("GAMEID") or envs.get("UMU_ID")
if game_id:
return game_id
games_path = os.path.join(settings.RUNTIME_DIR, "umu-games/umu-games.json")
if not os.path.exists(games_path):
return DEFAULT_GAMEID
with open(games_path, "r", encoding="utf-8") as games_file:
umu_games = json.load(games_file)
for umu_game in umu_games:
if (
umu_game["store"]