Philipp Hörist pushed to branch master at gajim / gajim


Commits:
ee0cf350 by André Apitzsch at 2020-11-06T18:31:56+01:00
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.

- - - - -
7439bbd9 by André Apitzsch at 2020-11-07T12:38:36+01:00
Init: Fix IS_PORTABLE check

- - - - -
70b6371a by André Apitzsch at 2020-11-07T12:39:04+01:00
Init: Remove os dependency

- - - - -


3 changed files:

- gajim/__init__.py
- gajim/common/configpaths.py
- win/misc/gajim-portable.nsi


Changes:

=====================================
gajim/__init__.py
=====================================
@@ -1,16 +1,13 @@
-import os
 import subprocess
+import sys
+from pathlib import Path
 
 __version__ = "1.2.91"
 
-IS_FLATPAK = False
-if os.path.exists('/app/share/run-as-flatpak'):
-    IS_FLATPAK = True
+IS_FLATPAK = Path('/app/share/run-as-flatpak').exists()
 
-IS_PORTABLE = False
-portable_path = os.path.join(os.getcwd(), 'is_portable')
-if os.path.exists(portable_path):
-    IS_PORTABLE = True
+portable_path = Path(sys.executable).parent / 'is_portable'
+IS_PORTABLE = portable_path.exists()
 
 try:
     p = subprocess.Popen('git rev-parse --short=12 HEAD', shell=True,


=====================================
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'


=====================================
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
 



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/compare/d5d99c66b8b6ec014621b620caf1b12c63215a81...70b6371ace80d6a331faafb6ac0942da217afcd9

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/compare/d5d99c66b8b6ec014621b620caf1b12c63215a81...70b6371ace80d6a331faafb6ac0942da217afcd9
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to