flatpak: Make things work without FLATPAK_ID

This commit is contained in:
Florian Bruhin 2021-03-30 21:55:47 +02:00
parent f35e284de0
commit 3b1bbc709c
2 changed files with 6 additions and 2 deletions

View File

@ -240,7 +240,8 @@ def _init_runtime(args: Optional[argparse.Namespace]) -> None:
# instances.
*parts, app_name = os.path.split(path)
assert app_name == APPNAME, app_name
path = os.path.join(*parts, 'app', os.environ['FLATPAK_ID'])
flatpak_id = os.environ.get('FLATPAK_ID', 'org.qutebrowser.qutebrowser')
path = os.path.join(*parts, 'app', flatpak_id)
_create(path)
_locations[_Location.runtime] = path

View File

@ -209,12 +209,15 @@ class TestStandardDir:
@pytest.mark.linux
@pytest.mark.parametrize('args_basedir', [True, False])
@pytest.mark.parametrize('has_flatpak_id', [True, False])
def test_flatpak_runtimedir(self, fake_flatpak, monkeypatch, tmp_path,
args_basedir):
args_basedir, has_flatpak_id):
runtime_path = tmp_path / 'runtime'
runtime_path.mkdir()
runtime_path.chmod(0o0700)
if not has_flatpak_id:
monkeypatch.delenv('FLATPAK_ID') # added in fake_flatpak
monkeypatch.setenv('XDG_RUNTIME_DIR', str(runtime_path))
if args_basedir: