Merge branch 'save-fifo' of https://github.com/Carpetsmoker/qutebrowser into Carpetsmoker-save-fifo

This commit is contained in:
Florian Bruhin 2015-07-02 19:16:04 +02:00
commit d44f14063a

View File

@ -296,10 +296,10 @@ class DownloadItem(QObject):
else:
self.set_fileobj(fileobj)
def _ask_overwrite_question(self):
def _ask_confirm_question(self, msg):
"""Create a Question object to be asked."""
q = usertypes.Question(self)
q.text = self._filename + " already exists. Overwrite? (y/n)"
q.text = msg + ' (N/y)'
q.mode = usertypes.PromptMode.yesno
q.answered_yes.connect(self._create_fileobj)
q.answered_no.connect(functools.partial(self.cancel, False))
@ -452,7 +452,14 @@ class DownloadItem(QObject):
if os.path.isfile(self._filename):
# The file already exists, so ask the user if it should be
# overwritten.
self._ask_overwrite_question()
self._ask_confirm_question(self._filename +
" already exists. Overwrite?")
# FIFO, device node, etc. Make sure we want to do this
elif (os.path.exists(self._filename) and not
os.path.isdir(self._filename)):
self._ask_confirm_question(self._filename +
" already exists and is a special file."
" Write to this?")
else:
self._create_fileobj()