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."
|
"Open file and ensure it's in the right format."
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def close(self) -> None:
|
||||||
|
"Closes the open file."
|
||||||
|
return
|
||||||
|
|
||||||
def importNotes(self, notes: List[ForeignNote]) -> None:
|
def importNotes(self, notes: List[ForeignNote]) -> None:
|
||||||
"Convert each card into a note, apply attributes and add to col."
|
"Convert each card into a note, apply attributes and add to col."
|
||||||
assert self.mappingOk()
|
assert self.mappingOk()
|
||||||
|
|
|
@ -361,6 +361,7 @@ def importFile(mw, file):
|
||||||
mw.progress.start(immediate=True)
|
mw.progress.start(immediate=True)
|
||||||
try:
|
try:
|
||||||
importer.open()
|
importer.open()
|
||||||
|
diag = ImportDialog(mw, importer)
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
mw.progress.finish()
|
mw.progress.finish()
|
||||||
showUnicodeWarning()
|
showUnicodeWarning()
|
||||||
|
@ -377,7 +378,7 @@ def importFile(mw, file):
|
||||||
return
|
return
|
||||||
finally:
|
finally:
|
||||||
mw.progress.finish()
|
mw.progress.finish()
|
||||||
diag = ImportDialog(mw, importer)
|
importer.close()
|
||||||
else:
|
else:
|
||||||
# if it's an apkg/zip, first test it's a valid file
|
# if it's an apkg/zip, first test it's a valid file
|
||||||
if importer.__class__.__name__ == "AnkiPackageImporter":
|
if importer.__class__.__name__ == "AnkiPackageImporter":
|
||||||
|
|
Loading…
Reference in a new issue