rename corrupt collection (#999)

if we don't do this, the user can never get back into the profile
in order to overwrite it with a backup
This commit is contained in:
Damien Elmes 2014-01-14 15:24:42 +09:00
parent 96eeacbf69
commit 227c5cbc94

View file

@ -264,15 +264,19 @@ To import into a password protected profile, please open the profile before atte
def loadCollection(self): def loadCollection(self):
self.hideSchemaMsg = True self.hideSchemaMsg = True
cpath = self.pm.collectionPath()
try: try:
self.col = Collection(self.pm.collectionPath(), log=True) self.col = Collection(cpath, log=True)
except anki.db.Error: except anki.db.Error:
# move back to profile manager # warn user
showWarning("""\ showWarning("""\
Your collection is corrupt. Please see the manual for \ Your collection is corrupt. Please see the manual for \
how to restore from a backup.""") how to restore from a backup.""")
self.unloadProfile() # move it out of the way so the profile can be used again
raise newpath = cpath+str(intTime())
os.rename(cpath, newpath)
# then close
sys.exit(1)
except Exception, e: except Exception, e:
# the custom exception handler won't catch this if we immediately # the custom exception handler won't catch this if we immediately
# unload, so we have to manually handle it # unload, so we have to manually handle it