From 0f8ec73c55c95d3934d76f77a34020494037a2d4 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Wed, 11 Nov 2015 20:05:42 +0100 Subject: [PATCH] mhtml: also check dir before starting the download Otherwise the downloads will be useless anyway. --- qutebrowser/browser/mhtml.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/qutebrowser/browser/mhtml.py b/qutebrowser/browser/mhtml.py index dad2ad63f..b9be58dc3 100644 --- a/qutebrowser/browser/mhtml.py +++ b/qutebrowser/browser/mhtml.py @@ -510,6 +510,14 @@ def start_download_checked(dest, win_id, tab_id): default_name, os.path.join(downloads.download_dir(), dest)) downloads.last_used_directory = os.path.dirname(path) + # Avoid downloading files if we can't save the output anyway... + # Yes, this is prone to race conditions, but we're checking again before + # saving the file anyway. + if not os.path.isdir(os.path.dirname(path)): + dir = os.path.dirname(path) + message.error(win_id, "Directory {} does not exist.".format(dir)) + return + if not os.path.isfile(path): _start_download(path, win_id=win_id, tab_id=tab_id) return