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) self.col = Collection(cpath, log=True)
except anki.db.Error: except anki.db.Error:
# warn user # warn user
showWarning("""\ showWarning(_("""\
Your collection is corrupt. Please see the manual for \ Your collection is corrupt. Please create a new profile, then \
how to restore from a backup."""+"\n\n"+_("Debug info:")+"\n"+traceback.format_exc()) see the manual for how to restore from an automatic backup.
# move it out of the way so the profile can be used again
newpath = cpath+str(intTime()) Debug info:
os.rename(cpath, newpath) """)+traceback.format_exc())
# then close self.unloadProfile()
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