mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 06:52:21 -04:00
import .apkg files in a background thread
This commit is contained in:
parent
231fa30a86
commit
ad9dad8748
1 changed files with 34 additions and 31 deletions
|
@ -395,11 +395,11 @@ def importFile(mw, file):
|
||||||
|
|
||||||
# importing non-colpkg files
|
# importing non-colpkg files
|
||||||
mw.progress.start(immediate=True)
|
mw.progress.start(immediate=True)
|
||||||
try:
|
|
||||||
try:
|
def on_done(future: Future):
|
||||||
importer.run()
|
|
||||||
finally:
|
|
||||||
mw.progress.finish()
|
mw.progress.finish()
|
||||||
|
try:
|
||||||
|
future.result()
|
||||||
except zipfile.BadZipfile:
|
except zipfile.BadZipfile:
|
||||||
showWarning(invalidZipMsg())
|
showWarning(invalidZipMsg())
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -429,8 +429,11 @@ Unable to import from a read-only file."""
|
||||||
tooltip(log)
|
tooltip(log)
|
||||||
else:
|
else:
|
||||||
showText(log)
|
showText(log)
|
||||||
|
|
||||||
mw.reset()
|
mw.reset()
|
||||||
|
|
||||||
|
mw.taskman.run_in_background(importer.run, on_done)
|
||||||
|
|
||||||
|
|
||||||
def invalidZipMsg():
|
def invalidZipMsg():
|
||||||
return _(
|
return _(
|
||||||
|
|
Loading…
Reference in a new issue