From c1ea82273b067246f4a497b0839bb0d2a8305518 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sun, 6 May 2012 17:53:18 +0900 Subject: [PATCH] log actual changes, not all prospectives --- anki/db.py | 4 ++++ anki/importing/noteimp.py | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/anki/db.py b/anki/db.py index 74cbcdf9b..356bcaa46 100644 --- a/anki/db.py +++ b/anki/db.py @@ -93,3 +93,7 @@ class DB(object): def __exit__(self, exc_type, *args): self._db.close() + + def totalChanges(self): + return self._db.total_changes + diff --git a/anki/importing/noteimp.py b/anki/importing/noteimp.py index abda40a9e..5517b3a2d 100644 --- a/anki/importing/noteimp.py +++ b/anki/importing/noteimp.py @@ -151,7 +151,7 @@ class NoteImporter(Importer): self.updateCards() # make sure to update sflds, etc self.log.append(_("%(a)d notes added, %(b)d notes updated.") % - dict(a=len(new), b=len(updates))) + dict(a=len(new), b=self.updateCount)) self.total = len(self._ids) def newData(self, n): @@ -186,9 +186,11 @@ class NoteImporter(Importer): id, n.fieldsStr, tags] def addUpdates(self, rows): + old = self.col.db.totalChanges() self.col.db.executemany(""" update notes set mod = ?, usn = ?, flds = ?, tags = ? where id = ? and (flds != ? or tags != ?)""", rows) + self.updateCount = self.col.db.totalChanges() - old def processFields(self, note, fields=None): if not fields: