protontricks
protontricks copied to clipboard
Skip corrupted manifest files
Corrupted manifest file currently cause the Python file parser to choke, leading to an unhandled exception e.g.:
Traceback (most recent call last):
File "/usr/bin/protontricks", line 310, in <module>
steam_apps = get_steam_apps(steam_lib_dirs)
File "/usr/bin/protontricks", line 250, in get_steam_apps
steam_app = SteamApp.from_appmanifest(path)
File "/usr/bin/protontricks", line 86, in from_appmanifest
content = f.read()
File "/usr/lib/python-exec/python3.6/../../../lib64/python3.6/codecs.py", line 321, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
Signed-off-by: Rob Walker [email protected]
What exception does the file parser raise in this case? It would be better to catch only that since we risk silently ignoring other errors.
@Matoking It's in the commit message. I was trying to install a protontricks override for a different game and the corrupt manifest file lead to that exception. Basically another of my Steam manifest files is corrupt (see attached). I agree it's a bit of a hack, but it's better than baling at the first corrupt manifest file!
I did try with a python-magic manfiest file pre-check, but didn't get very far with that. But perhaps that's another option?
The last line of your traceback seems to be missing, but I managed to reproduce the error: it's UnicodeDecodeError.
In this case I think
try:
f.read()
except UnicodeDecodeError:
return None
would be an alright solution that keeps the script running while not being too broad.
On that note, was the corrupted appmanifest created by Steam or some third-party tool? I had an empty appmanifest pop up in one of my Steam library folders, but I figured it was due to the game having been uninstalled and the file staying behind for some reason. File corruption seems like a far more severe problem.