mirror of
https://github.com/lutris/lutris
synced 2024-09-18 15:22:27 +00:00
Add defensive 'except' clauses for cases where the Steam VDF file is unreadable
Steam corruption shouldn't prevent Lutris from working outside of Steam support. This PR logs the errors, but continues. Steam functionality may not work, but everything else will.
This commit is contained in:
parent
30d1ee3e97
commit
6a4150f628
|
@ -252,7 +252,7 @@ class LutrisInitDialog(Gtk.Dialog):
|
|||
|
||||
def init_cb(self, _result, error):
|
||||
if error:
|
||||
ErrorDialog(str(error))
|
||||
ErrorDialog(str(error), parent=self)
|
||||
self.destroy()
|
||||
|
||||
def on_response(self, _widget, response):
|
||||
|
|
|
@ -26,7 +26,7 @@ def get_shortcuts_vdf_path():
|
|||
|
||||
|
||||
def vdf_file_exists():
|
||||
return bool(get_shortcuts_vdf_path)
|
||||
return bool(get_shortcuts_vdf_path())
|
||||
|
||||
|
||||
def matches_id(shortcut, game):
|
||||
|
@ -39,12 +39,18 @@ def matches_id(shortcut, game):
|
|||
|
||||
|
||||
def shortcut_exists(game):
|
||||
shortcut_path = get_shortcuts_vdf_path()
|
||||
if not shortcut_path or not os.path.exists(shortcut_path):
|
||||
try:
|
||||
shortcut_path = get_shortcuts_vdf_path()
|
||||
if not shortcut_path or not os.path.exists(shortcut_path):
|
||||
return False
|
||||
|
||||
with open(shortcut_path, "rb") as shortcut_file:
|
||||
shortcuts = vdf.binary_loads(shortcut_file.read())['shortcuts'].values()
|
||||
|
||||
return bool([s for s in shortcuts if matches_id(s, game)])
|
||||
except Exception as ex:
|
||||
logger.error("Failed to read shortcut vdf file: %s", ex)
|
||||
return False
|
||||
with open(shortcut_path, "rb") as shortcut_file:
|
||||
shortcuts = vdf.binary_loads(shortcut_file.read())['shortcuts'].values()
|
||||
return bool([s for s in shortcuts if matches_id(s, game)])
|
||||
|
||||
|
||||
def is_steam_game(game):
|
||||
|
@ -150,15 +156,19 @@ def set_artwork(game):
|
|||
|
||||
|
||||
def update_all_artwork():
|
||||
shortcut_path = get_shortcuts_vdf_path()
|
||||
if not shortcut_path or not os.path.exists(shortcut_path):
|
||||
return
|
||||
with open(shortcut_path, "rb") as shortcut_file:
|
||||
shortcuts = vdf.binary_loads(shortcut_file.read())['shortcuts'].values()
|
||||
for shortcut in shortcuts:
|
||||
id_match = re.match(r".*lutris:rungameid/(\d+)", shortcut["LaunchOptions"])
|
||||
if not id_match:
|
||||
continue
|
||||
game_id = int(id_match.groups()[0])
|
||||
game = Game(game_id)
|
||||
set_artwork(game)
|
||||
try:
|
||||
shortcut_path = get_shortcuts_vdf_path()
|
||||
if not shortcut_path or not os.path.exists(shortcut_path):
|
||||
return
|
||||
with open(shortcut_path, "rb") as shortcut_file:
|
||||
shortcuts = vdf.binary_loads(shortcut_file.read())['shortcuts'].values()
|
||||
for shortcut in shortcuts:
|
||||
id_match = re.match(r".*lutris:rungameid/(\d+)", shortcut["LaunchOptions"])
|
||||
if not id_match:
|
||||
continue
|
||||
game_id = int(id_match.groups()[0])
|
||||
game = Game(game_id)
|
||||
set_artwork(game)
|
||||
except Exception as ex:
|
||||
logger.error("Failed to update steam shortcut artwork: %s", ex)
|
||||
raise ex
|
||||
|
|
Loading…
Reference in a new issue