Merge branch 'Kingdread-issue-2173'
This commit is contained in:
commit
59b378e29a
@ -573,13 +573,16 @@ class AbstractDownloadItem(QObject):
|
|||||||
"""Set a temporary file when opening the download."""
|
"""Set a temporary file when opening the download."""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def _set_filename(self, filename, *, force_overwrite=False):
|
def _set_filename(self, filename, *, force_overwrite=False,
|
||||||
|
remember_directory=True):
|
||||||
"""Set the filename to save the download to.
|
"""Set the filename to save the download to.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
filename: The full filename to save the download to.
|
filename: The full filename to save the download to.
|
||||||
None: special value to stop the download.
|
None: special value to stop the download.
|
||||||
force_overwrite: Force overwriting existing files.
|
force_overwrite: Force overwriting existing files.
|
||||||
|
remember_directory: If True, remember the directory for future
|
||||||
|
downloads.
|
||||||
"""
|
"""
|
||||||
global last_used_directory
|
global last_used_directory
|
||||||
filename = os.path.expanduser(filename)
|
filename = os.path.expanduser(filename)
|
||||||
@ -609,6 +612,7 @@ class AbstractDownloadItem(QObject):
|
|||||||
os.path.expanduser('~'))
|
os.path.expanduser('~'))
|
||||||
|
|
||||||
self.basename = os.path.basename(self._filename)
|
self.basename = os.path.basename(self._filename)
|
||||||
|
if remember_directory:
|
||||||
last_used_directory = os.path.dirname(self._filename)
|
last_used_directory = os.path.dirname(self._filename)
|
||||||
|
|
||||||
log.downloads.debug("Setting filename to {}".format(filename))
|
log.downloads.debug("Setting filename to {}".format(filename))
|
||||||
|
@ -96,7 +96,8 @@ class DownloadItem(downloads.AbstractDownloadItem):
|
|||||||
raise downloads.UnsupportedOperationError
|
raise downloads.UnsupportedOperationError
|
||||||
|
|
||||||
def _set_tempfile(self, fileobj):
|
def _set_tempfile(self, fileobj):
|
||||||
self._set_filename(fileobj.name, force_overwrite=True)
|
self._set_filename(fileobj.name, force_overwrite=True,
|
||||||
|
remember_directory=False)
|
||||||
|
|
||||||
def _ensure_can_set_filename(self, filename):
|
def _ensure_can_set_filename(self, filename):
|
||||||
state = self._qt_item.state()
|
state = self._qt_item.state()
|
||||||
|
@ -438,6 +438,21 @@ Feature: Downloading things from a website.
|
|||||||
And I open data/downloads/download2.bin without waiting
|
And I open data/downloads/download2.bin without waiting
|
||||||
Then the download prompt should be shown with "(tmpdir)/download2.bin"
|
Then the download prompt should be shown with "(tmpdir)/download2.bin"
|
||||||
|
|
||||||
|
# https://github.com/The-Compiler/qutebrowser/issues/2173
|
||||||
|
|
||||||
|
Scenario: Remembering the temporary download directory (issue 2173)
|
||||||
|
When I set storage -> prompt-download-directory to true
|
||||||
|
And I set completion -> download-path-suggestion to both
|
||||||
|
And I set storage -> remember-download-directory to true
|
||||||
|
And I open data/downloads/download.bin without waiting
|
||||||
|
And I wait for the download prompt for "*"
|
||||||
|
And I run :prompt-accept (tmpdir)
|
||||||
|
And I open data/downloads/download.bin without waiting
|
||||||
|
And I wait for the download prompt for "*"
|
||||||
|
And I directly open the download
|
||||||
|
And I open data/downloads/download.bin without waiting
|
||||||
|
Then the download prompt should be shown with "(tmpdir)/download.bin"
|
||||||
|
|
||||||
# Overwriting files
|
# Overwriting files
|
||||||
|
|
||||||
Scenario: Not overwriting an existing file
|
Scenario: Not overwriting an existing file
|
||||||
|
Loading…
Reference in New Issue
Block a user