warn when prefs.db corrupt and catch another case
This commit is contained in:
parent
26a3c30365
commit
99c90b929b
@ -187,9 +187,20 @@ documentation for information on using a flash drive.""")
|
|||||||
path = os.path.join(self.base, "prefs.db")
|
path = os.path.join(self.base, "prefs.db")
|
||||||
new = not os.path.exists(path)
|
new = not os.path.exists(path)
|
||||||
self.db = DB(path, text=str)
|
self.db = DB(path, text=str)
|
||||||
self.db.execute("""
|
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
|
create table if not exists profiles
|
||||||
(name text primary key, data text not null);""")
|
(name text primary key, data text not null);""")
|
||||||
|
except:
|
||||||
|
recover()
|
||||||
|
return self._loadMeta()
|
||||||
if not new:
|
if not new:
|
||||||
# load previously created
|
# load previously created
|
||||||
try:
|
try:
|
||||||
@ -198,8 +209,7 @@ create table if not exists profiles
|
|||||||
"select data from profiles where name = '_global'"))
|
"select data from profiles where name = '_global'"))
|
||||||
return
|
return
|
||||||
except:
|
except:
|
||||||
# if we can't load profile, start with a new one
|
recover()
|
||||||
os.rename(path, path+".broken")
|
|
||||||
return self._loadMeta()
|
return self._loadMeta()
|
||||||
# create a default global profile
|
# create a default global profile
|
||||||
self.meta = metaConf.copy()
|
self.meta = metaConf.copy()
|
||||||
|
Loading…
Reference in New Issue
Block a user