mirror of
https://github.com/ankitects/anki.git
synced 2025-09-23 16:26:40 -04:00
Explicitly close the importer file descriptor
https://github.com/ankitects/anki/pull 613
This commit is contained in:
parent
efb62b9528
commit
200bad3714
2 changed files with 6 additions and 1 deletions
|
@ -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()
|
||||
|
|
|
@ -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":
|
||||
|
|
Loading…
Reference in a new issue