mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 23:12:21 -04:00
report more info when note type changes prevent an import
This commit is contained in:
parent
e73bfa9d02
commit
0c2a1fe19e
1 changed files with 14 additions and 5 deletions
|
@ -68,6 +68,7 @@ class Anki2Importer(Importer):
|
||||||
dirty = []
|
dirty = []
|
||||||
usn = self.dst.usn()
|
usn = self.dst.usn()
|
||||||
dupes = 0
|
dupes = 0
|
||||||
|
dupesIgnored = []
|
||||||
for note in self.src.db.execute(
|
for note in self.src.db.execute(
|
||||||
"select * from notes"):
|
"select * from notes"):
|
||||||
# turn the db result into a mutable list
|
# turn the db result into a mutable list
|
||||||
|
@ -89,22 +90,30 @@ class Anki2Importer(Importer):
|
||||||
else:
|
else:
|
||||||
# a duplicate or changed schema - safe to update?
|
# a duplicate or changed schema - safe to update?
|
||||||
dupes += 1
|
dupes += 1
|
||||||
if self.allowUpdate and note[GUID] in self._notes:
|
if self.allowUpdate:
|
||||||
oldNid, oldMod, oldMid = self._notes[note[GUID]]
|
oldNid, oldMod, oldMid = self._notes[note[GUID]]
|
||||||
# safe if note types identical
|
# will update if incoming note more recent
|
||||||
if oldMid == note[MID]:
|
if oldMod < note[MOD]:
|
||||||
# will update if incoming note more recent
|
# safe if note types identical
|
||||||
if oldMod < note[MOD]:
|
if oldMid == note[MID]:
|
||||||
# incoming note should use existing id
|
# incoming note should use existing id
|
||||||
note[0] = oldNid
|
note[0] = oldNid
|
||||||
note[4] = usn
|
note[4] = usn
|
||||||
note[6] = self._mungeMedia(note[MID], note[6])
|
note[6] = self._mungeMedia(note[MID], note[6])
|
||||||
update.append(note)
|
update.append(note)
|
||||||
dirty.append(note[0])
|
dirty.append(note[0])
|
||||||
|
else:
|
||||||
|
dupesIgnored.append("%s: %s" % (
|
||||||
|
self.col.models.get(oldMid)['name'],
|
||||||
|
note[6].replace("\x1f", ",")
|
||||||
|
))
|
||||||
if dupes:
|
if dupes:
|
||||||
up = len(update)
|
up = len(update)
|
||||||
self.log.append(_("Updated %(a)d of %(b)d existing notes.") % dict(
|
self.log.append(_("Updated %(a)d of %(b)d existing notes.") % dict(
|
||||||
a=len(update), b=dupes))
|
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
|
# export info for calling code
|
||||||
self.dupes = dupes
|
self.dupes = dupes
|
||||||
self.added = len(add)
|
self.added = len(add)
|
||||||
|
|
Loading…
Reference in a new issue