make sure we can write the deck, so we can warn w/ apkg too

This commit is contained in:
Damien Elmes 2012-04-06 19:29:00 +09:00
parent e89ccaa18b
commit 5ba108b53b

View file

@ -1,6 +1,7 @@
# Copyright: Damien Elmes <anki@ichi2.net> # Copyright: Damien Elmes <anki@ichi2.net>
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import os
from aqt.qt import * from aqt.qt import *
import anki, aqt, aqt.tagedit import anki, aqt, aqt.tagedit
from aqt.utils import getSaveFile, tooltip, showWarning from aqt.utils import getSaveFile, tooltip, showWarning
@ -53,10 +54,13 @@ class ExportDialog(QDialog):
self.exporter.did = self.col.decks.id(name) self.exporter.did = self.col.decks.id(name)
self.mw.progress.start(immediate=True) self.mw.progress.start(immediate=True)
try: try:
self.exporter.exportInto(file) f = open(file, "wb")
f.close()
except (OSError, IOError), e: except (OSError, IOError), e:
showWarning(_("Couldn't save file: %s") % unicode(e)) showWarning(_("Couldn't save file: %s") % unicode(e))
else: else:
os.unlink(file)
self.exporter.exportInto(file)
tooltip(_("%d exported.") % self.exporter.count) tooltip(_("%d exported.") % self.exporter.count)
finally: finally:
self.mw.progress.finish() self.mw.progress.finish()