From ddde036e3a073fc49d4e9b4b5838f8c18d7f532b Mon Sep 17 00:00:00 2001 From: Zestyr Date: Mon, 19 Jun 2017 19:21:59 +0200 Subject: [PATCH] Add check for old folder locations --- CHANGELOG.md | 6 +++--- lbrynet/conf.py | 43 +++++++++++++++++++++++++++++-------------- 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a5c9971e3..bc80f6b94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,9 +13,9 @@ at anytime. * ### Changed - * Linux data folder changed from `.lbrynet` to `~/.local/share/LBRY` - * Linux config folder changed from `.lbryum` to `~/.config/LBRY` - * Linux downloads folder changed from `~/Downloads` to `XDG_DOWNLOAD_DIR` + * Linux default downloads folder changed from `~/Downloads` to `XDG_DOWNLOAD_DIR` + * Linux folders moved from the home directory to `~/.local/share/LBRY` + * Windows folders moved from `%APPDATA%/Roaming/lbry` to `%APPDATA%/Local/LBRY` ### Fixed * Fixed some log messages throwing exceptions diff --git a/lbrynet/conf.py b/lbrynet/conf.py index 4d4d88358..e9555b3e2 100644 --- a/lbrynet/conf.py +++ b/lbrynet/conf.py @@ -54,24 +54,39 @@ elif 'nt' in sys.platform: from lbrynet.winhelpers.knownpaths import get_path, FOLDERID, UserHandle default_download_dir = get_path(FOLDERID.Downloads, UserHandle.current) - default_data_dir = user_data_dir('lbrynet', 'LBRY', roaming=True) - default_lbryum_dir = user_data_dir('lbryum', 'LBRY', roaming=True) + + # This checks whether the folders are still in their old locations + if os.path.isdir(user_data_dir('lbryum', 'lbry', roaming=True)) and \ + os.path.isdir(user_data_dir('lbrynet', 'lbry', roaming=True)): + default_data_dir = user_data_dir('lbrynet', 'lbry', roaming=True) + default_lbryum_dir = user_data_dir('lbryum', 'lbry', roaming=True) + else: + default_data_dir = user_data_dir('lbrynet', 'LBRY') + default_lbryum_dir = user_data_dir('lbryum', 'LBRY') + else: platform = LINUX - try: - with open(os.path.join(user_config_dir(), "/user-dirs.dirs"), 'r') as xdg: - down_dir = re.search(r'XDG_DOWNLOAD_DIR=(.+)', xdg.read()).group(1) - down_dir = re.sub('\$HOME', os.getenv('HOME'), down_dir) - default_download_dir = re.sub('\"', "", down_dir) - except: - default_download_dir = os.getenv('XDG_DOWNLOAD_DIR') - finally: - if not default_download_dir: - default_download_dir = os.path.join(os.getenv('HOME'), 'Downloads') + # This checks whether the folders are still in their old locations + if os.path.isdir(os.path.expanduser('~/.lbrynet')) and \ + os.path.isdir(os.path.expanduser('~/.lbryum')): + default_data_dir = os.path.expanduser('~/.lbrynet') + default_lbryum_dir = os.path.expanduser('~/.lbryum') + default_download_dir = os.path.expanduser('~/Downloads') + else: + default_data_dir = user_data_dir('LBRY/lbrynet') + default_lbryum_dir = user_data_dir('LBRY/lbryum') + try: + with open(os.path.join(user_config_dir(), 'user-dirs.dirs'), 'r') as xdg: + down_dir = re.search(r'XDG_DOWNLOAD_DIR=(.+)', xdg.read()).group(1) + down_dir = re.sub('\$HOME', os.getenv('HOME'), down_dir) + default_download_dir = re.sub('\"', '', down_dir) + except: + default_download_dir = os.getenv('XDG_DOWNLOAD_DIR') + + if not default_download_dir: + default_download_dir = os.path.expanduser('~/Downloads') - default_data_dir = user_data_dir('LBRY') - default_lbryum_dir = user_config_dir('LBRY') ICON_PATH = 'icons' if platform is WINDOWS else 'app.icns'