initial zip check should display same zip error message

This commit is contained in:
Damien Elmes 2014-06-29 05:55:01 +09:00
parent ec5d4b2203
commit 0abcc7412f

View File

@ -317,7 +317,7 @@ backup, please see the 'Backups' section of the user manual."""))
try:
z.getinfo("collection.anki2")
except:
showWarning(_("The provided file is not a valid .apkg file."))
showWarning(invalidZipMsg())
return
# we need to ask whether to import/replace
if not setupApkgImport(mw, importer):
@ -326,12 +326,7 @@ backup, please see the 'Backups' section of the user manual."""))
try:
importer.run()
except zipfile.BadZipfile:
msg = _("""\
This file does not appear to be a valid .apkg file. If you're getting this \
error from a file downloaded from AnkiWeb, chances are that your download \
failed. Please try again, and if the problem persists, please try again \
with a different browser.""")
showWarning(msg)
showWarning(invalidZipMsg())
except Exception, e:
err = repr(str(e))
if "invalidFile" in err:
@ -357,6 +352,13 @@ Unable to import from a read-only file."""))
mw.progress.finish()
mw.reset()
def invalidZipMsg():
return _("""\
This file does not appear to be a valid .apkg file. If you're getting this \
error from a file downloaded from AnkiWeb, chances are that your download \
failed. Please try again, and if the problem persists, please try again \
with a different browser.""")
def setupApkgImport(mw, importer):
base = os.path.basename(importer.file).lower()
full = (base == "collection.apkg") or re.match("backup-.*\\.apkg", base)