From 61b0072dcc8350893cb3372b4343883e408c9e06 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Fri, 27 Jun 2014 04:25:40 +0900 Subject: [PATCH] fix handling of corrupt collections on windows - advise user to create new profile, which prevents restores from backup overwriting old backups - don't rename the collection file, as it's no longer necessary, and it fixes a windows bug where the main window would be left open due to a failure to rename the locked collection file --- aqt/main.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/aqt/main.py b/aqt/main.py index 1b9e440ed..ec92db8bd 100644 --- a/aqt/main.py +++ b/aqt/main.py @@ -271,14 +271,13 @@ To import into a password protected profile, please open the profile before atte self.col = Collection(cpath, log=True) except anki.db.Error: # warn user - showWarning("""\ -Your collection is corrupt. Please see the manual for \ -how to restore from a backup."""+"\n\n"+_("Debug info:")+"\n"+traceback.format_exc()) - # 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) + showWarning(_("""\ +Your collection is corrupt. Please create a new profile, then \ +see the manual for how to restore from an automatic backup. + +Debug info: +""")+traceback.format_exc()) + self.unloadProfile() except Exception, e: # the custom exception handler won't catch this if we immediately # unload, so we have to manually handle it