diff --git a/pylib/anki/importing/noteimp.py b/pylib/anki/importing/noteimp.py index cce0cc328..753b2f94c 100644 --- a/pylib/anki/importing/noteimp.py +++ b/pylib/anki/importing/noteimp.py @@ -107,6 +107,10 @@ class NoteImporter(Importer): "Open file and ensure it's in the right format." return + def close(self) -> None: + "Closes the open file." + return + def importNotes(self, notes: List[ForeignNote]) -> None: "Convert each card into a note, apply attributes and add to col." assert self.mappingOk() diff --git a/qt/aqt/importing.py b/qt/aqt/importing.py index 7c757cd48..b0feac7c7 100644 --- a/qt/aqt/importing.py +++ b/qt/aqt/importing.py @@ -361,6 +361,7 @@ def importFile(mw, file): mw.progress.start(immediate=True) try: importer.open() + diag = ImportDialog(mw, importer) except UnicodeDecodeError: mw.progress.finish() showUnicodeWarning() @@ -377,7 +378,7 @@ def importFile(mw, file): return finally: mw.progress.finish() - diag = ImportDialog(mw, importer) + importer.close() else: # if it's an apkg/zip, first test it's a valid file if importer.__class__.__name__ == "AnkiPackageImporter":