more usn fixes

This commit is contained in:
Damien Elmes 2011-12-14 10:27:20 +09:00
parent 819bc326e0
commit 2c0b3f7c0a

View file

@ -67,6 +67,7 @@ class Anki2Importer(Importer):
# iterate over source collection # iterate over source collection
add = [] add = []
dirty = [] dirty = []
usn = self.dst.usn()
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
@ -84,7 +85,7 @@ class Anki2Importer(Importer):
note[2] = lmid note[2] = lmid
note[3] = self._did(note[3]) note[3] = self._did(note[3])
note[4] = intTime() note[4] = intTime()
note[5] = -1 # usn note[5] = usn
add.append(note) add.append(note)
dirty.append(note[0]) dirty.append(note[0])
# note we have the added note # note we have the added note
@ -189,6 +190,7 @@ class Anki2Importer(Importer):
cards = [] cards = []
revlog = [] revlog = []
cnt = 0 cnt = 0
usn = self.dst.usn()
aheadBy = self.src.sched.today - self.dst.sched.today aheadBy = self.src.sched.today - self.dst.sched.today
for card in self.src.db.execute( for card in self.src.db.execute(
"select f.guid, f.mid, c.* from cards c, notes f " "select f.guid, f.mid, c.* from cards c, notes f "
@ -214,6 +216,7 @@ class Anki2Importer(Importer):
card[1] = self._notes[guid][0] card[1] = self._notes[guid][0]
card[2] = self._did(card[2]) card[2] = self._did(card[2])
card[4] = intTime() card[4] = intTime()
card[5] = usn
# review cards have a due date relative to collection # review cards have a due date relative to collection
if card[7] == 2: if card[7] == 2:
card[8] -= aheadBy card[8] -= aheadBy