From 0c2a1fe19e6c3b2debd8404819aedbbbe284f74a Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Wed, 4 Sep 2013 02:19:15 +0900 Subject: [PATCH] report more info when note type changes prevent an import --- anki/importing/anki2.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/anki/importing/anki2.py b/anki/importing/anki2.py index 758e8fe51..ce1e304f6 100644 --- a/anki/importing/anki2.py +++ b/anki/importing/anki2.py @@ -68,6 +68,7 @@ class Anki2Importer(Importer): dirty = [] usn = self.dst.usn() dupes = 0 + dupesIgnored = [] for note in self.src.db.execute( "select * from notes"): # turn the db result into a mutable list @@ -89,22 +90,30 @@ class Anki2Importer(Importer): else: # a duplicate or changed schema - safe to update? dupes += 1 - if self.allowUpdate and note[GUID] in self._notes: + if self.allowUpdate: oldNid, oldMod, oldMid = self._notes[note[GUID]] - # safe if note types identical - if oldMid == note[MID]: - # will update if incoming note more recent - if oldMod < note[MOD]: + # will update if incoming note more recent + if oldMod < note[MOD]: + # safe if note types identical + if oldMid == note[MID]: # incoming note should use existing id note[0] = oldNid note[4] = usn note[6] = self._mungeMedia(note[MID], note[6]) update.append(note) dirty.append(note[0]) + else: + dupesIgnored.append("%s: %s" % ( + self.col.models.get(oldMid)['name'], + note[6].replace("\x1f", ",") + )) if dupes: up = len(update) self.log.append(_("Updated %(a)d of %(b)d existing notes.") % dict( a=len(update), b=dupes)) + if dupesIgnored: + self.log.append(_("Some updates were ignored because note type has changed:")) + self.log.extend(dupesIgnored) # export info for calling code self.dupes = dupes self.added = len(add)