From beb15d9b774aa6b79cf35ba5495948cc175f667d Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Wed, 25 Sep 2019 18:20:51 +0300 Subject: [PATCH] Try using ANDROID_PRIVATE instead of HOME if not found --- src/paths.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/paths.py b/src/paths.py index ada54c8e..ac526a74 100644 --- a/src/paths.py +++ b/src/paths.py @@ -52,20 +52,27 @@ def lookupAppdataFolder(): sys.getfilesystemencoding(), 'ignore'), APPNAME ) + os.path.sep else: - try: - dataFolder = os.path.join(os.environ['XDG_CONFIG_HOME'], APPNAME) - except KeyError: - dataFolder = os.path.join(os.environ['HOME'], '.config', APPNAME) + homedir = os.environ.get('XDG_CONFIG_HOME') + if not homedir: + try: + homedir = os.path.join(os.environ['HOME'], '.config') + except KeyError: + # Nonstandard environment, try android vars + homedir = os.environ.get('ANDROID_PRIVATE') + + dataFolder = os.path.join(homedir, APPNAME) # Migrate existing data to the proper location # if this is an existing install try: - move(os.path.join(os.environ['HOME'], '.%s' % APPNAME), dataFolder) + move( + os.path.join(os.environ.get('HOME', ''), '.%s' % APPNAME), + dataFolder) logger.info('Moving data folder to %s', dataFolder) except IOError: # Old directory may not exist. pass - dataFolder = dataFolder + os.path.sep + dataFolder += os.path.sep return dataFolder