downloads: don't crash on OSError in open-download

Fixes the crash in #1725, but does not provide a solution. The browser
won't crash, but the file won't be downloaded and opened either.
This commit is contained in:
Daniel Schadt 2016-08-02 00:46:59 +02:00
parent ef439bb916
commit 9973cd5037

View File

@ -947,7 +947,13 @@ class DownloadManager(QAbstractListModel):
download.set_filename(target.filename)
elif isinstance(target, usertypes.OpenFileDownloadTarget):
tmp_manager = objreg.get('temporary-downloads')
fobj = tmp_manager.get_tmpfile(suggested_filename)
try:
fobj = tmp_manager.get_tmpfile(suggested_filename)
except OSError as exc:
msg = "Download error: {}".format(exc)
message.error(self._win_id, msg)
download.cancel()
return
download.finished.connect(download.open_file)
download.autoclose = True
download.set_fileobj(fobj)