import .apkg files in a background thread
This commit is contained in:
parent
231fa30a86
commit
ad9dad8748
@ -395,41 +395,44 @@ def importFile(mw, file):
|
|||||||
|
|
||||||
# importing non-colpkg files
|
# importing non-colpkg files
|
||||||
mw.progress.start(immediate=True)
|
mw.progress.start(immediate=True)
|
||||||
try:
|
|
||||||
|
def on_done(future: Future):
|
||||||
|
mw.progress.finish()
|
||||||
try:
|
try:
|
||||||
importer.run()
|
future.result()
|
||||||
finally:
|
except zipfile.BadZipfile:
|
||||||
mw.progress.finish()
|
showWarning(invalidZipMsg())
|
||||||
except zipfile.BadZipfile:
|
except Exception as e:
|
||||||
showWarning(invalidZipMsg())
|
err = repr(str(e))
|
||||||
except Exception as e:
|
if "invalidFile" in err:
|
||||||
err = repr(str(e))
|
msg = _(
|
||||||
if "invalidFile" in err:
|
|
||||||
msg = _(
|
|
||||||
"""\
|
|
||||||
Invalid file. Please restore from backup."""
|
|
||||||
)
|
|
||||||
showWarning(msg)
|
|
||||||
elif "invalidTempFolder" in err:
|
|
||||||
showWarning(mw.errorHandler.tempFolderMsg())
|
|
||||||
elif "readonly" in err:
|
|
||||||
showWarning(
|
|
||||||
_(
|
|
||||||
"""\
|
"""\
|
||||||
Unable to import from a read-only file."""
|
Invalid file. Please restore from backup."""
|
||||||
)
|
)
|
||||||
)
|
showWarning(msg)
|
||||||
|
elif "invalidTempFolder" in err:
|
||||||
|
showWarning(mw.errorHandler.tempFolderMsg())
|
||||||
|
elif "readonly" in err:
|
||||||
|
showWarning(
|
||||||
|
_(
|
||||||
|
"""\
|
||||||
|
Unable to import from a read-only file."""
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
msg = tr(TR.IMPORTING_FAILED_DEBUG_INFO) + "\n"
|
||||||
|
msg += str(traceback.format_exc())
|
||||||
|
showText(msg)
|
||||||
else:
|
else:
|
||||||
msg = tr(TR.IMPORTING_FAILED_DEBUG_INFO) + "\n"
|
log = "\n".join(importer.log)
|
||||||
msg += str(traceback.format_exc())
|
if "\n" not in log:
|
||||||
showText(msg)
|
tooltip(log)
|
||||||
else:
|
else:
|
||||||
log = "\n".join(importer.log)
|
showText(log)
|
||||||
if "\n" not in log:
|
|
||||||
tooltip(log)
|
mw.reset()
|
||||||
else:
|
|
||||||
showText(log)
|
mw.taskman.run_in_background(importer.run, on_done)
|
||||||
mw.reset()
|
|
||||||
|
|
||||||
|
|
||||||
def invalidZipMsg():
|
def invalidZipMsg():
|
||||||
|
Loading…
Reference in New Issue
Block a user