From 227c5cbc9426dc6eee938212da6d85d42c7f5e6c Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Tue, 14 Jan 2014 15:24:42 +0900 Subject: [PATCH] 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 --- aqt/main.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/aqt/main.py b/aqt/main.py index 608cec7ee..5fe6bf3f5 100644 --- a/aqt/main.py +++ b/aqt/main.py @@ -264,15 +264,19 @@ To import into a password protected profile, please open the profile before atte def loadCollection(self): self.hideSchemaMsg = True + cpath = self.pm.collectionPath() try: - self.col = Collection(self.pm.collectionPath(), log=True) + self.col = Collection(cpath, log=True) except anki.db.Error: - # move back to profile manager + # warn user showWarning("""\ Your collection is corrupt. Please see the manual for \ how to restore from a backup.""") - self.unloadProfile() - raise + # move it out of the way so the profile can be used again + newpath = cpath+str(intTime()) + os.rename(cpath, newpath) + # then close + sys.exit(1) except Exception, e: # the custom exception handler won't catch this if we immediately # unload, so we have to manually handle it