Skip to content

Commit

Permalink
Ignore empty compatibilitytool.vdf
Browse files Browse the repository at this point in the history
Ignore empty compatibilitytool.vdf file when looking for custom Proton
installations. It is unknown what causes these empty manifests to be
created in the first place. In any case, the Steam client ignores the
installations, so do the same here.

Fixes #241
  • Loading branch information
Matoking committed Jan 4, 2024
1 parent 3bb2496 commit de708dc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [Unreleased]
### Fixed
- Fix Protontricks crash when custom Proton has an empty `compatibilitytool.vdf` manifest

## [1.11.0] - 2023-12-30
### Added
- Show app icons for custom shortcuts in the app selector
Expand Down
8 changes: 8 additions & 0 deletions src/protontricks/steam.py
Original file line number Diff line number Diff line change
Expand Up @@ -1007,6 +1007,14 @@ def get_custom_compat_tool_installations_in_dir(compat_tool_dir):
)
continue

if not vdf_data:
logger.warning(
"Compatibility tool declaration at %s is empty. You may need "
"to reinstall the application.",
vdf_path
)
continue

# Traverse to 'compatibilitytools/compat_tools' in a case-insensitive
# way. This is done because we can't turn all keys recursively to
# lowercase from the get-go; the app name is stored as a key.
Expand Down
18 changes: 12 additions & 6 deletions tests/test_steam.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,16 +741,24 @@ def test_get_steam_apps_custom_proton_empty_toolmanifest(
"Tool manifest for Custom Proton is empty"
)

@pytest.mark.parametrize(
"content,error",
[
(b"corrupted", " is corrupted. "),
(b"", " is empty. ") # Regression test for #241
]
)
def test_get_steam_apps_custom_proton_corrupted_compatibilitytool(
self, custom_proton_factory, steam_dir, steam_root, caplog):
self, custom_proton_factory, steam_dir, steam_root, caplog,
content, error):
"""
Create a custom Proton installation with a corrupted
compatibilitytool.vdf and ensure a warning is printed and the app
is ignored
"""
custom_proton = custom_proton_factory(name="Custom Proton")
(custom_proton.install_path / "compatibilitytool.vdf").write_text(
"corrupted"
(custom_proton.install_path / "compatibilitytool.vdf").write_bytes(
content
)

steam_apps = get_steam_apps(
Expand All @@ -774,9 +782,7 @@ def test_get_steam_apps_custom_proton_corrupted_compatibilitytool(
if record.levelname == "WARNING"
)

assert record.getMessage().startswith(
"Compatibility tool declaration at"
)
assert error in record.getMessage()

def test_get_steam_apps_in_library_folder(
self, default_proton, steam_library_factory, steam_app_factory,
Expand Down

0 comments on commit de708dc

Please sign in to comment.