Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

Skip corrupted manifest files #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bobwya
Copy link
Contributor

@bobwya bobwya commented Nov 14, 2018

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]

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]>
@Matoking
Copy link
Contributor

Matoking commented Nov 14, 2018

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.

@bobwya
Copy link
Contributor Author

bobwya commented Nov 14, 2018

@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!

appmanifest_339790.acf.zip

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?

@Matoking
Copy link
Contributor

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants