From 26ed58349e8496d592734cd0b398360725ecba04 Mon Sep 17 00:00:00 2001 From: Christopher Liebich Kolle Date: Sat, 13 Apr 2024 23:03:45 +0200 Subject: [PATCH] Fix NoneType error in get_game_id function --- lutris/util/wine/proton.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lutris/util/wine/proton.py b/lutris/util/wine/proton.py index 1d5c60aac..30755efd0 100644 --- a/lutris/util/wine/proton.py +++ b/lutris/util/wine/proton.py @@ -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"]