diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ff429c..547efb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/protontricks/steam.py b/src/protontricks/steam.py index cabdd7e..403ef39 100644 --- a/src/protontricks/steam.py +++ b/src/protontricks/steam.py @@ -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. diff --git a/tests/test_steam.py b/tests/test_steam.py index 24ee3b4..f990334 100644 --- a/tests/test_steam.py +++ b/tests/test_steam.py @@ -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( @@ -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,