Skip to content

Commit

Permalink
Fix duplicate app entries
Browse files Browse the repository at this point in the history
Steam now lists the main installation path itself in the
`libraryfolders.vdf`. This path can also have a different path but
resolve to one of the existing paths due to one of them being a symlink.
This results in Protontricks finding duplicate appmanifest files unless
the duplicate library paths are removed.

Fixes #118
  • Loading branch information
Matoking committed Oct 7, 2021
1 parent 1d5431e commit db2796b
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
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 duplicate Steam application entries

## [1.6.0] - 2021-08-08
### Added
- Add `protontricks-launch` script to launch Windows executables using Proton app specific Wine prefixes
Expand Down
9 changes: 8 additions & 1 deletion src/protontricks/steam.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,14 @@ def parse_library_folders(data):
)
) from exc

return [steam_path] + library_folders
paths = [steam_path] + library_folders

# Get rid of duplicate paths by fully resolving them and turning them into
# a set and back
paths = [path.resolve() for path in paths]
paths = list(set(paths))

return paths


def get_compat_tool_dirs(steam_root):
Expand Down
32 changes: 32 additions & 0 deletions tests/test_steam.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,38 @@ def test_get_steam_lib_paths_corrupted_libraryfolders(

assert "Library folder configuration file" in str(exc.value)

def test_get_steam_lib_paths_duplicate_paths(
self, steam_dir, steam_library_factory):
"""
Retrive Steam library folders and ensure duplicate paths (eg.
an existing path OR a symlink that resolves to an existing path)
are removed from the returned list.
Regression test for #118
"""
library_dir = steam_library_factory("TestLibrary_A")

# Create a symlink from TestLibrary_B to TestLibrary_A
(library_dir.parent / "TestLibrary_B").symlink_to(library_dir)

# Add the duplicate library folder
vdf_data = vdf.loads(
(steam_dir / "steamapps" / "libraryfolders.vdf").read_text()
)
vdf_data["LibraryFolders"]["2"] = str(
library_dir.parent / "TestLibrary_B"
)
(steam_dir / "steamapps" / "libraryfolders.vdf").write_text(
vdf.dumps(vdf_data)
)

library_paths = get_steam_lib_paths(steam_dir)

# Only two paths should be returned
assert len(library_paths) == 2
assert steam_dir in library_paths
assert library_dir in library_paths


class TestFindAppidProtonPrefix:
def test_find_appid_proton_prefix_steamapps_case(
Expand Down

0 comments on commit db2796b

Please sign in to comment.