summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCalum Lind <calumlind+deluge@gmail.com>2014-02-03 12:26:57 +0000
committerCalum Lind <calumlind+deluge@gmail.com>2014-02-09 19:12:59 +0000
commit9f75d4597eec96b167a47fa7b56207ec489f8cea (patch)
tree0aa39c28e22a026e32343540b005cab3199d5a4c
parentffc48d381063378934ddcdc2902533ac3fc8a72c (diff)
downloaddeluge-9f75d4597eec96b167a47fa7b56207ec489f8cea.tar.gz
deluge-9f75d4597eec96b167a47fa7b56207ec489f8cea.tar.bz2
deluge-9f75d4597eec96b167a47fa7b56207ec489f8cea.zip
Change get_default_download_dir to use expanduser as fallback
-rw-r--r--deluge/common.py19
1 files changed, 8 insertions, 11 deletions
diff --git a/deluge/common.py b/deluge/common.py
index 99866d071..90f440322 100644
--- a/deluge/common.py
+++ b/deluge/common.py
@@ -173,22 +173,19 @@ def get_default_download_dir():
:rtype: string
"""
- if windows_check():
- return os.path.join(os.path.expanduser("~"), 'Downloads')
- else:
+ download_dir = ""
+ if not windows_check():
from xdg.BaseDirectory import xdg_config_home
- userdir_file = os.path.join(xdg_config_home, 'user-dirs.dirs')
try:
- for line in open(userdir_file, 'r'):
- if not line.startswith('#') and 'XDG_DOWNLOAD_DIR' in line:
- download_dir = os.path.expandvars(\
- line.partition("=")[2].rstrip().strip('"'))
- if os.path.isdir(download_dir):
- return download_dir
+ for line in open(os.path.join(xdg_config_home, 'user-dirs.dirs'), 'r'):
+ if not line.startswith('#') and line.startswith('XDG_DOWNLOAD_DIR'):
+ download_dir = os.path.expandvars(line.partition("=")[2].rstrip().strip('"'))
except IOError:
pass
- return os.environ.get("HOME")
+ if not download_dir:
+ download_dir = os.path.join(os.path.expanduser("~"), 'Downloads')
+ return download_dir
def windows_check():
"""