Skip to content

Commit e74bf7a

Browse files
committed
Fix disabled Flatpak filesystem permission check
Return all found Steam library paths in `get_steam_lib_paths`, even those not found in the filesystem. Due to earlier refactoring, the function checked which directories were accessible in the filesystem and only returned those. The return value was used by `prompt_filesystem_access`; any paths were obviously already accessible in the sandbox, meaning the function would never find any inaccessible paths and prompt the user. Also add new regression test that tests this behavior by running an actual Protontricks command while mocking the Python FS call to hide the directory. An existing unit test for the Flatpak permission check was insufficient as it only tested the prompt check in isolation with a hardcoded list of paths. Fixes #472
1 parent 4b433f9 commit e74bf7a

4 files changed

Lines changed: 71 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
88
### Fixed
99
- Fix Steam installation being prompted twice when using `protontricks-launch`
1010
- Fix Steam Runtime crash if it's installed under a blacklisted root directory (eg. `/run/<path>` instead of `/run/media/<path>`)
11+
- Fix missing filesystem permissions not being detected under Flatpak
1112

1213
## [1.14.0] - 2026-02-22
1314
### Added

src/protontricks/steam.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,11 @@ def resolve_library_folder(path):
10651065
"exist",
10661066
path
10671067
)
1068-
return None
1068+
# If the path does not exist, return it anyway; if we're
1069+
# inside a Flatpak sandbox we'll need the path to perform
1070+
# a permission check. Missing permission might explain why the
1071+
# directory appears nonexistent.
1072+
return Path(path)
10691073

10701074
# In case of multiple matches, prioritize those that contain
10711075
# a 'steamapps' subdirectory

tests/cli/test_main.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import os
22
import sys
33
import shutil
4+
from glob import glob
5+
46
from pathlib import Path
57

68
import pytest
@@ -737,6 +739,7 @@ def test_steam_installation_not_selected(self, cli, gui_provider):
737739
assert "No Steam installation was selected" in result
738740

739741

742+
740743
class TestCLIGUI:
741744
def test_run_gui(
742745
self, cli, default_proton, steam_app_factory, gui_provider,
@@ -1123,3 +1126,64 @@ def test_cli_enable_logging(cli, parameter, log_levels):
11231126

11241127
assert "DEBUG" not in stderr
11251128
assert "INFO" not in stderr
1129+
1130+
1131+
@pytest.mark.usefixtures("flatpak_sandbox")
1132+
def test_inaccessible_path_prompted(
1133+
cli, tmp_path, steam_library_factory, monkeypatch, steam_dir,
1134+
gui_provider):
1135+
"""
1136+
Test that an inaccessible path is prompted when the user
1137+
is inside a Flatpak sandbox and the directory does not appear
1138+
to exist, usually because it's not mounted in the sandbox and
1139+
requires a permission first.
1140+
1141+
Regression test for #472
1142+
"""
1143+
flatpak_info_path = tmp_path / "flatpak-info"
1144+
1145+
flatpak_info_path.write_text(
1146+
"[Application]\n"
1147+
"name=fake.flatpak.Protontricks\n"
1148+
"\n"
1149+
"[Instance]\n"
1150+
"flatpak-version=1.12.1\n"
1151+
"\n"
1152+
"[Context]\n"
1153+
f"filesystems={steam_dir}"
1154+
)
1155+
monkeypatch.setattr(
1156+
"protontricks.flatpak.FLATPAK_INFO_PATH", str(flatpak_info_path)
1157+
)
1158+
library_dir = steam_library_factory("hidden-library")
1159+
1160+
# Mock 'glob' so that it conceals the existence of the library
1161+
# directory.
1162+
mock_glob_called = False
1163+
def mock_glob(path):
1164+
results = glob(path)
1165+
results = [
1166+
path for path in results
1167+
if path != str(library_dir)
1168+
]
1169+
1170+
nonlocal mock_glob_called
1171+
mock_glob_called = True
1172+
1173+
return results
1174+
1175+
# Mock the user closing the dialog without ignoring the messages
1176+
gui_provider.returncode = 1
1177+
1178+
with monkeypatch.context() as m:
1179+
m.setattr("glob.glob", mock_glob)
1180+
cli(["--no-term", "-s", "app"])
1181+
1182+
input_ = gui_provider.kwargs["input"].decode("utf-8")
1183+
1184+
# Ensure the 'hidden-library' is listed among the directories to enable
1185+
# and that the mocked glob was actually used
1186+
assert "does not appear to have access" in input_
1187+
assert str(library_dir) in input_
1188+
1189+
assert mock_glob_called is True

tests/test_steam.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ def test_get_steam_lib_paths_missing_library_parent(
665665
lib_paths = get_steam_lib_paths(steam_dir)
666666

667667
assert library_dir_a in lib_paths
668-
assert library_dir_b not in lib_paths
668+
assert library_dir_b in lib_paths
669669
assert library_dir_c in lib_paths
670670

671671
assert any(

0 commit comments

Comments
 (0)