From ee0cf3500c722507311bf1b422045c2d76dd1ef5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Apitzsch?= <git@apitzsch.eu> Date: Fri, 6 Nov 2020 18:31:56 +0100 Subject: [PATCH] Portable: Move config path parameter to application If a user called bin/Gajim.exe directly config_path parameter was ignored, which could lead to problems with non-portable user settings. --- gajim/common/configpaths.py | 9 +++++---- win/misc/gajim-portable.nsi | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/gajim/common/configpaths.py b/gajim/common/configpaths.py index 20a37946a3..0ac8793143 100644 --- a/gajim/common/configpaths.py +++ b/gajim/common/configpaths.py @@ -105,13 +105,14 @@ def __init__(self) -> None: self.custom_config_root = None # type: Optional[Path] if os.name == 'nt': - try: + if gajim.IS_PORTABLE: + application_path = Path(sys.executable).parent + self.config_root = self.cache_root = self.data_root = \ + application_path.parent / 'UserData' + else: # Documents and Settings\[User Name]\Application Data\Gajim self.config_root = self.cache_root = self.data_root = \ Path(os.environ['appdata']) / 'Gajim' - except KeyError: - # win9x, in cwd - self.config_root = self.cache_root = self.data_root = Path('.') else: self.config_root = Path(GLib.get_user_config_dir()) / 'gajim' self.cache_root = Path(GLib.get_user_cache_dir()) / 'gajim' diff --git a/win/misc/gajim-portable.nsi b/win/misc/gajim-portable.nsi index 86d05c0aa2..e16592c398 100644 --- a/win/misc/gajim-portable.nsi +++ b/win/misc/gajim-portable.nsi @@ -105,9 +105,9 @@ Section "Gajim" SecGajim SetOutPath "$INSTDIR\bin" CreateShortCut "$INSTDIR\Gajim-Portable.lnk" "$INSTDIR\bin\Gajim.exe" \ - "-c ..\UserData" "" "" SW_SHOWNORMAL "" "Gajim Portable" + "" "" "" SW_SHOWNORMAL "" "Gajim Portable" CreateShortCut "$INSTDIR\Gajim-Portable-Debug.lnk" "$INSTDIR\bin\Gajim-Debug.exe" \ - "-c ..\UserData" "" "" SW_SHOWNORMAL "" "Gajim Portable Debug" + "" "" "" SW_SHOWNORMAL "" "Gajim Portable Debug" FileOpen $0 "is_portable" w FileClose $0 -- GitLab