fix config error if $HOME is None

-not seen on travis due to HOME being manually set to /tmp
This commit is contained in:
Jack Robison 2019-01-24 12:42:55 -05:00
parent 80440fd6bd
commit 77ece96356
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2

View file

@ -507,11 +507,10 @@ def get_linux_directories() -> typing.Tuple[str, str, str]:
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)
down_dir = re.sub('\$HOME', os.getenv('HOME') or os.path.expanduser("~/"), down_dir)
download_dir = re.sub('\"', '', down_dir)
except EnvironmentError:
download_dir = os.getenv('XDG_DOWNLOAD_DIR')
if not download_dir:
download_dir = os.path.expanduser('~/Downloads')