downloads: Be okay with the tmpdir being gone
This commit is contained in:
parent
38a3d118ab
commit
2388489038
@ -1376,7 +1376,11 @@ class TempDownloadManager(QObject):
|
|||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
"""Clean up any temporary files."""
|
"""Clean up any temporary files."""
|
||||||
if self._tmpdir is not None:
|
if self._tmpdir is not None:
|
||||||
|
try:
|
||||||
self._tmpdir.cleanup()
|
self._tmpdir.cleanup()
|
||||||
|
except OSError:
|
||||||
|
log.misc.exception("Failed to clean up temporary download "
|
||||||
|
"directory")
|
||||||
self._tmpdir = None
|
self._tmpdir = None
|
||||||
|
|
||||||
def _get_tmpdir(self):
|
def _get_tmpdir(self):
|
||||||
|
@ -323,6 +323,16 @@ Feature: Downloading things from a website.
|
|||||||
And I wait until the download is finished
|
And I wait until the download is finished
|
||||||
Then "Opening *download.bin* with [*python*]" should be logged
|
Then "Opening *download.bin* with [*python*]" should be logged
|
||||||
|
|
||||||
|
Scenario: Opening a download with a handler which deletes the tmpdir
|
||||||
|
When I set storage -> prompt-download-directory to true
|
||||||
|
And I open data/downloads/download.bin
|
||||||
|
And I directly open the download with a handler deleting the tmpdir
|
||||||
|
And I wait until the download is finished
|
||||||
|
And I run :quit
|
||||||
|
Then "Opening *download.bin* with [*python*]" should be logged
|
||||||
|
And "Failed to clean up temporary download directory" should be logged
|
||||||
|
And qutebrowser should quit
|
||||||
|
|
||||||
# https://github.com/The-Compiler/qutebrowser/issues/1728
|
# https://github.com/The-Compiler/qutebrowser/issues/1728
|
||||||
|
|
||||||
Scenario: Cancelling a download that should be opened
|
Scenario: Cancelling a download that should be opened
|
||||||
|
@ -126,6 +126,14 @@ def download_open_with_prompt(quteproc):
|
|||||||
quteproc.send_cmd(':prompt-open-download {}'.format(cmd))
|
quteproc.send_cmd(':prompt-open-download {}'.format(cmd))
|
||||||
|
|
||||||
|
|
||||||
|
@bdd.when("I directly open the download with a handler deleting the tmpdir")
|
||||||
|
def download_open_with_prompt_deleting(quteproc):
|
||||||
|
cmd = ('{} -c "import sys, shutil, os.path; '
|
||||||
|
'shutil.rmtree(os.path.dirname(sys.argv[1]))"'.format(
|
||||||
|
shlex.quote(sys.executable)))
|
||||||
|
quteproc.send_cmd(':prompt-open-download {}'.format(cmd))
|
||||||
|
|
||||||
|
|
||||||
@bdd.when(bdd.parsers.parse("I delete the downloaded file {filename}"))
|
@bdd.when(bdd.parsers.parse("I delete the downloaded file {filename}"))
|
||||||
def delete_file(tmpdir, filename):
|
def delete_file(tmpdir, filename):
|
||||||
(tmpdir / filename).remove()
|
(tmpdir / filename).remove()
|
||||||
|
Loading…
Reference in New Issue
Block a user