make sure we're only writing the config once; fix speed regressions in browser

This commit is contained in:
Damien Elmes 2011-03-15 07:09:29 +09:00
parent 2e327f4fe9
commit 8e7ed0acc9
2 changed files with 6 additions and 4 deletions

View file

@ -98,12 +98,14 @@ class Config(object):
self.db.executescript("""
create table if not exists decks (path text primary key);
create table if not exists config (conf text not null);
insert or ignore into config values ('');""")
""")
conf = self.db.scalar("select conf from config")
if conf:
self._conf.update(cPickle.loads(conf))
else:
self._conf.update(defaultConf)
# ensure there's something to update
self.db.execute("insert or ignore into config values ('')")
self._addDefaults()
def save(self):

View file

@ -19,7 +19,7 @@ hr { margin: 5 0 5 0; }
a:hover { background-color: #aaa; }
a { color: #000; text-decoration: none; }
.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; }
"""
@ -236,7 +236,7 @@ later by using File>Close.
try:
mod = os.stat(d)[stat.ST_MTIME]
t = time.time()
deck = Deck(d)
deck = Deck(d, lock=False)
counts = deck.sched.counts()
dtime = deck.sched.timeToday()
dreps = deck.sched.repsToday()
@ -251,7 +251,7 @@ later by using File>Close.
'time': dtime,
'reps': dreps
})
deck.close()
deck.close(save=False)
# reset modification time for the sake of backup systems
try:
os.utime(d, (mod, mod))