Matoking / protontricks

A wrapper that does winetricks things for Proton enabled games, requires Winetricks.
GNU General Public License v3.0
1.66k stars 36 forks source link

find_proton_app expects magic number in appinfo.vdf that isn't portable #23

Closed kira-bruneau closed 5 years ago

kira-bruneau commented 5 years ago

@aanderse encountered a crash while trying to test out a new package for protontricks on NixOS: NixOS/nixpkgs/pull/64705.

~> protontricks --gui
Traceback (most recent call last):
  File "/nix/store/6slrbp5hb8ijd5gv7fb6k80jmp8g3176-protontricks-1.2.2/bin/.protontricks-wrapped", line 11, in <module>
    sys.exit(main())
  File "/nix/store/6slrbp5hb8ijd5gv7fb6k80jmp8g3176-protontricks-1.2.2/lib/python3.7/site-packages/protontricks/cli.py", line 178, in main
    steam_path=steam_path, steam_apps=steam_apps, appid=steam_app.appid
  File "/nix/store/6slrbp5hb8ijd5gv7fb6k80jmp8g3176-protontricks-1.2.2/lib/python3.7/site-packages/protontricks/steam.py", line 356, in find_proton_app
    steam_path=steam_path, steam_apps=steam_apps, appid=appid)
  File "/nix/store/6slrbp5hb8ijd5gv7fb6k80jmp8g3176-protontricks-1.2.2/lib/python3.7/site-packages/protontricks/steam.py", line 317, in find_steam_proton_app
    proton_appid = re.search(appid_regex, appinfo).group(2)
AttributeError: 'NoneType' object has no attribute 'group'

The issue was narrowed down to find_proton_app using a magic number in a regex when trying to lookup up the proton app id. This magic number should probably be made more generic, or the binary API for vdf should be used instead.

https://github.com/Matoking/protontricks/blob/7f90359eb6fbbc84b57b2e6ef374535c7a9ecf95/src/protontricks/steam.py#L309-L318

Matoking commented 5 years ago

I looked into this a bit and found vdf library developer's comment on appinfo.vdf file structure here.

I've pushed a change to the appinfo_parse branch that should allow the file to be parsed properly without having to deal with flaky regexes. Can you test if it works?

kira-bruneau commented 5 years ago

It seems to be working for me, but @aanderse was the one who originally encountered the crash.

From at ValvePython/vdf#13 (comment) it looks like the app section contains a size. I'm assuming that describes the size of the vdf_data, so could that be used to speed up the parsing?

EDIT: I didn't see the "for real this time" commit, looks good :+1:

Matoking commented 5 years ago

Issue was discussed at NixOS/nixpkgs#64705 and the resulting bug fix has been merged into master.