more helpful error message for corrupt collection package

This commit is contained in:
Soren I. Bjornstad 2014-06-17 16:55:55 -05:00
parent 8620b81817
commit ebcab2122d

View File

@ -379,7 +379,11 @@ def replaceWithApkg(mw, file, backup):
mw.unloadCollection()
# overwrite collection
z = zipfile.ZipFile(file)
z.extract("collection.anki2", mw.pm.profileFolder())
try:
z.extract("collection.anki2", mw.pm.profileFolder())
except:
showWarning(_("The provided file is not a valid .apkg file."))
return
# because users don't have a backup of media, it's safer to import new
# data and rely on them running a media db check to get rid of any
# unwanted media. in the future we might also want to deduplicate this