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
This commit is contained in:
Damien Elmes 2014-06-27 04:25:40 +09:00
parent 2aa7714f87
commit 61b0072dcc

View file

@ -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