Explicitly close the importer file descriptor

https://github.com/ankitects/anki/pull 613
This commit is contained in:
evandrocoan 2020-05-12 11:15:01 -03:00
parent efb62b9528
commit 200bad3714
2 changed files with 6 additions and 1 deletions

View file

@ -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()

View file

@ -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":