mirror of
https://github.com/ankitects/anki.git
synced 2025-11-07 05:07:10 -05:00
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:
parent
96eeacbf69
commit
227c5cbc94
1 changed files with 8 additions and 4 deletions
12
aqt/main.py
12
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
|
||||
|
|
|
|||
Loading…
Reference in a new issue