Also don't create ~/Downloads in standarddir.downloads()
This means we need to create it in downloads.py instead. Fixes #2418
This commit is contained in:
parent
91f5e72f02
commit
2d500d4efa
@ -73,11 +73,18 @@ def download_dir():
|
|||||||
remember_dir = config.val.downloads.location.remember
|
remember_dir = config.val.downloads.location.remember
|
||||||
|
|
||||||
if remember_dir and last_used_directory is not None:
|
if remember_dir and last_used_directory is not None:
|
||||||
return last_used_directory
|
ddir = last_used_directory
|
||||||
elif directory is None:
|
elif directory is None:
|
||||||
return standarddir.download()
|
ddir = standarddir.download()
|
||||||
else:
|
else:
|
||||||
return directory
|
ddir = directory
|
||||||
|
|
||||||
|
try:
|
||||||
|
os.makedirs(ddir)
|
||||||
|
except FileExistsError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return ddir
|
||||||
|
|
||||||
|
|
||||||
def immediate_download_path(prompt_download_directory=None):
|
def immediate_download_path(prompt_download_directory=None):
|
||||||
|
@ -118,12 +118,12 @@ def _init_download(args):
|
|||||||
"""Initialize the location for downloads.
|
"""Initialize the location for downloads.
|
||||||
|
|
||||||
Note this is only the default directory as found by Qt.
|
Note this is only the default directory as found by Qt.
|
||||||
|
Therefore, we also don't create it.
|
||||||
"""
|
"""
|
||||||
typ = QStandardPaths.DownloadLocation
|
typ = QStandardPaths.DownloadLocation
|
||||||
overridden, path = _from_args(typ, args)
|
overridden, path = _from_args(typ, args)
|
||||||
if not overridden:
|
if not overridden:
|
||||||
path = _writable_location(typ)
|
path = _writable_location(typ)
|
||||||
_create(path)
|
|
||||||
_locations[Location.download] = path
|
_locations[Location.download] = path
|
||||||
|
|
||||||
|
|
||||||
|
@ -418,3 +418,15 @@ def test_init(mocker, tmpdir, with_args):
|
|||||||
assert standarddir._locations != {}
|
assert standarddir._locations != {}
|
||||||
if with_args:
|
if with_args:
|
||||||
assert m.called
|
assert m.called
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.linux
|
||||||
|
def test_downloads_dir_not_crated(monkeypatch, tmpdir):
|
||||||
|
"""Make sure ~/Downloads is not created."""
|
||||||
|
download_dir = tmpdir / 'Downloads'
|
||||||
|
monkeypatch.setenv('HOME', str(tmpdir))
|
||||||
|
# Make sure xdg-user-dirs.dirs is not picked up
|
||||||
|
monkeypatch.delenv('XDG_CONFIG_HOME', raising=False)
|
||||||
|
standarddir._init_dirs()
|
||||||
|
assert standarddir.download() == str(download_dir)
|
||||||
|
assert not download_dir.exists()
|
||||||
|
Loading…
Reference in New Issue
Block a user