mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 08:46:37 -04:00
don't bump mod time unless the db has actually been changed
This commit is contained in:
parent
0ff59b87e9
commit
cdb33cf6a8
3 changed files with 18 additions and 6 deletions
|
@ -96,15 +96,18 @@ conf, models, decks, dconf, tags from col""")
|
|||
crt=?, mod=?, scm=?, dty=?, usn=?, ls=?, conf=?""",
|
||||
self.crt, self.mod, self.scm, self.dty,
|
||||
self._usn, self.ls, simplejson.dumps(self.conf))
|
||||
self.models.flush()
|
||||
self.decks.flush()
|
||||
self.tags.flush()
|
||||
|
||||
def save(self, name=None, mod=None):
|
||||
"Flush, commit DB, and take out another write lock."
|
||||
self.flush(mod=mod)
|
||||
self.db.commit()
|
||||
self.lock()
|
||||
# let the managers conditionally flush
|
||||
self.models.flush()
|
||||
self.decks.flush()
|
||||
self.tags.flush()
|
||||
# and flush deck + bump mod if db has been changed
|
||||
if self.db.mod:
|
||||
self.flush(mod=mod)
|
||||
self.db.commit()
|
||||
self.lock()
|
||||
self._markOp(name)
|
||||
self._lastSave = time.time()
|
||||
|
||||
|
|
|
@ -17,8 +17,14 @@ class DB(object):
|
|||
self._db.text_factory = text
|
||||
self._path = path
|
||||
self.echo = os.environ.get("DBECHO")
|
||||
self.mod = False
|
||||
|
||||
def execute(self, sql, *a, **ka):
|
||||
s = sql.strip().lower()
|
||||
# mark modified?
|
||||
for stmt in "insert", "update", "delete":
|
||||
if s.startswith(stmt):
|
||||
self.mod = True
|
||||
if self.echo:
|
||||
print sql #, a, ka
|
||||
if ka:
|
||||
|
@ -30,6 +36,7 @@ class DB(object):
|
|||
return res
|
||||
|
||||
def executemany(self, sql, l):
|
||||
self.mod = True
|
||||
if self.echo:
|
||||
print sql #, l
|
||||
self._db.executemany(sql, l)
|
||||
|
@ -38,6 +45,7 @@ class DB(object):
|
|||
self._db.commit()
|
||||
|
||||
def executescript(self, sql):
|
||||
self.mod = True
|
||||
if self.echo:
|
||||
print sql
|
||||
self._db.executescript(sql)
|
||||
|
|
|
@ -29,6 +29,7 @@ defaultDeck = {
|
|||
'lrnToday': [0, 0],
|
||||
'timeToday': [0, 0], # time in ms
|
||||
'conf': 1,
|
||||
'usn': 0,
|
||||
}
|
||||
|
||||
# configuration only available to top level decks
|
||||
|
|
Loading…
Reference in a new issue