mirror of
https://github.com/ankitects/anki.git
synced 2025-11-13 08:07:11 -05:00
make sure we're only writing the config once; fix speed regressions in browser
This commit is contained in:
parent
2e327f4fe9
commit
8e7ed0acc9
2 changed files with 6 additions and 4 deletions
|
|
@ -98,12 +98,14 @@ class Config(object):
|
||||||
self.db.executescript("""
|
self.db.executescript("""
|
||||||
create table if not exists decks (path text primary key);
|
create table if not exists decks (path text primary key);
|
||||||
create table if not exists config (conf text not null);
|
create table if not exists config (conf text not null);
|
||||||
insert or ignore into config values ('');""")
|
""")
|
||||||
conf = self.db.scalar("select conf from config")
|
conf = self.db.scalar("select conf from config")
|
||||||
if conf:
|
if conf:
|
||||||
self._conf.update(cPickle.loads(conf))
|
self._conf.update(cPickle.loads(conf))
|
||||||
else:
|
else:
|
||||||
self._conf.update(defaultConf)
|
self._conf.update(defaultConf)
|
||||||
|
# ensure there's something to update
|
||||||
|
self.db.execute("insert or ignore into config values ('')")
|
||||||
self._addDefaults()
|
self._addDefaults()
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ hr { margin: 5 0 5 0; }
|
||||||
a:hover { background-color: #aaa; }
|
a:hover { background-color: #aaa; }
|
||||||
a { color: #000; text-decoration: none; }
|
a { color: #000; text-decoration: none; }
|
||||||
.num { text-align: right; padding: 0 5 0 5; }
|
.num { text-align: right; padding: 0 5 0 5; }
|
||||||
td.opts { text-align: right; }
|
td.opts { text-align: right; white-space: nowrap; }
|
||||||
a.opts { font-size: 80%; padding: 2; background-color: #ccc; border-radius: 2px; }
|
a.opts { font-size: 80%; padding: 2; background-color: #ccc; border-radius: 2px; }
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
@ -236,7 +236,7 @@ later by using File>Close.
|
||||||
try:
|
try:
|
||||||
mod = os.stat(d)[stat.ST_MTIME]
|
mod = os.stat(d)[stat.ST_MTIME]
|
||||||
t = time.time()
|
t = time.time()
|
||||||
deck = Deck(d)
|
deck = Deck(d, lock=False)
|
||||||
counts = deck.sched.counts()
|
counts = deck.sched.counts()
|
||||||
dtime = deck.sched.timeToday()
|
dtime = deck.sched.timeToday()
|
||||||
dreps = deck.sched.repsToday()
|
dreps = deck.sched.repsToday()
|
||||||
|
|
@ -251,7 +251,7 @@ later by using File>Close.
|
||||||
'time': dtime,
|
'time': dtime,
|
||||||
'reps': dreps
|
'reps': dreps
|
||||||
})
|
})
|
||||||
deck.close()
|
deck.close(save=False)
|
||||||
# reset modification time for the sake of backup systems
|
# reset modification time for the sake of backup systems
|
||||||
try:
|
try:
|
||||||
os.utime(d, (mod, mod))
|
os.utime(d, (mod, mod))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue