mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 15:32:23 -04:00
if global profile can't be loaded, start with new prefs.db
This commit is contained in:
parent
6415474db4
commit
d05331d31c
1 changed files with 16 additions and 11 deletions
|
@ -193,18 +193,23 @@ documentation for information on using a flash drive.""")
|
||||||
self.db.execute("""
|
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);""")
|
||||||
if new:
|
if not new:
|
||||||
# create a default global profile
|
|
||||||
self.meta = metaConf.copy()
|
|
||||||
self.db.execute("insert into profiles values ('_global', ?)",
|
|
||||||
cPickle.dumps(metaConf))
|
|
||||||
self._setDefaultLang()
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
# load previously created
|
# load previously created
|
||||||
self.meta = cPickle.loads(
|
try:
|
||||||
self.db.scalar(
|
self.meta = cPickle.loads(
|
||||||
"select data from profiles where name = '_global'"))
|
self.db.scalar(
|
||||||
|
"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")
|
||||||
|
return self._loadMeta()
|
||||||
|
# create a default global profile
|
||||||
|
self.meta = metaConf.copy()
|
||||||
|
self.db.execute("insert or replace into profiles values ('_global', ?)",
|
||||||
|
cPickle.dumps(metaConf))
|
||||||
|
self._setDefaultLang()
|
||||||
|
return True
|
||||||
|
|
||||||
def ensureProfile(self):
|
def ensureProfile(self):
|
||||||
"Create a new profile if none exists."
|
"Create a new profile if none exists."
|
||||||
|
|
Loading…
Reference in a new issue