mirror of
https://github.com/ankitects/anki.git
synced 2025-11-07 13:17:12 -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):
|
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
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue