mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-02 22:48:40 +00:00
Change get_default_download_dir to use expanduser as fallback
This commit is contained in:
parent
ffc48d3810
commit
9f75d4597e
1 changed files with 8 additions and 11 deletions
|
@ -173,22 +173,19 @@ def get_default_download_dir():
|
||||||
:rtype: string
|
:rtype: string
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if windows_check():
|
download_dir = ""
|
||||||
return os.path.join(os.path.expanduser("~"), 'Downloads')
|
if not windows_check():
|
||||||
else:
|
|
||||||
from xdg.BaseDirectory import xdg_config_home
|
from xdg.BaseDirectory import xdg_config_home
|
||||||
userdir_file = os.path.join(xdg_config_home, 'user-dirs.dirs')
|
|
||||||
try:
|
try:
|
||||||
for line in open(userdir_file, 'r'):
|
for line in open(os.path.join(xdg_config_home, 'user-dirs.dirs'), 'r'):
|
||||||
if not line.startswith('#') and 'XDG_DOWNLOAD_DIR' in line:
|
if not line.startswith('#') and line.startswith('XDG_DOWNLOAD_DIR'):
|
||||||
download_dir = os.path.expandvars(\
|
download_dir = os.path.expandvars(line.partition("=")[2].rstrip().strip('"'))
|
||||||
line.partition("=")[2].rstrip().strip('"'))
|
|
||||||
if os.path.isdir(download_dir):
|
|
||||||
return download_dir
|
|
||||||
except IOError:
|
except IOError:
|
||||||
pass
|
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():
|
def windows_check():
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue