mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
warn when prefs.db corrupt and catch another case
This commit is contained in:
parent
26a3c30365
commit
99c90b929b
1 changed files with 13 additions and 3 deletions
|
@ -187,9 +187,20 @@ documentation for information on using a flash drive.""")
|
|||
path = os.path.join(self.base, "prefs.db")
|
||||
new = not os.path.exists(path)
|
||||
self.db = DB(path, text=str)
|
||||
def recover():
|
||||
# if we can't load profile, start with a new one
|
||||
os.rename(path, path+".broken")
|
||||
QMessageBox.warning(
|
||||
None, "Preferences Corrupt", """\
|
||||
Anki's prefs.db file was corrupt and has been recreated. If you were using multiple \
|
||||
profiles, please add them back using the same names to recover your cards.""")
|
||||
try:
|
||||
self.db.execute("""
|
||||
create table if not exists profiles
|
||||
(name text primary key, data text not null);""")
|
||||
except:
|
||||
recover()
|
||||
return self._loadMeta()
|
||||
if not new:
|
||||
# load previously created
|
||||
try:
|
||||
|
@ -198,8 +209,7 @@ create table if not exists profiles
|
|||
"select data from profiles where name = '_global'"))
|
||||
return
|
||||
except:
|
||||
# if we can't load profile, start with a new one
|
||||
os.rename(path, path+".broken")
|
||||
recover()
|
||||
return self._loadMeta()
|
||||
# create a default global profile
|
||||
self.meta = metaConf.copy()
|
||||
|
|
Loading…
Reference in a new issue