make sure we adjust due time on reviews when importing

This commit is contained in:
Damien Elmes 2011-12-13 04:20:05 +09:00
parent 35a10744a6
commit c1d9b62549
3 changed files with 6 additions and 16 deletions

View file

@ -177,20 +177,6 @@ crt=?, mod=?, scm=?, dty=?, usn=?, ls=?, conf=?""",
self.sched.onClose()
self.dty = False
def rename(self, path):
raise "nyi"
# close our DB connection
self.close()
# move to new path
shutil.copy2(self.path, path)
os.unlink(self.path)
# record old dir
olddir = self.media.dir()
# reconnect & move media
self.path = path
self.reopen()
self.media.move(olddir)
def usn(self):
return self._usn if self.server else -1

View file

@ -90,7 +90,8 @@ class Anki2Importer(Importer):
# note we have the added note
self._notes[guid] = (note[0], note[4], note[2])
else:
print "merging notes nyi"
# not yet implemented
pass
# add to col
self.dst.db.executemany(
"insert or replace into notes values (?,?,?,?,?,?,?,?,?,?,?,?)",
@ -183,6 +184,7 @@ class Anki2Importer(Importer):
cards = []
revlog = []
cnt = 0
aheadBy = self.src.sched.today - self.dst.sched.today
for card in self.src.db.execute(
"select f.guid, f.mid, c.* from cards c, notes f "
"where c.nid = f.id"):
@ -207,6 +209,9 @@ class Anki2Importer(Importer):
card[1] = self._notes[guid][0]
card[2] = self._did(card[2])
card[4] = intTime()
# review cards have a due date relative to collection
if card[7] == 2:
card[8] -= aheadBy
cards.append(card)
# we need to import revlog, rewriting card ids
for rev in self.src.db.execute(

View file

@ -628,7 +628,6 @@ update cards set due = cast(
col.conf['nextPos'] = (
col.db.scalar("select max(id) from notes") or 0)+1
col.save()
# optimize and finish
col.db.commit()
col.db.execute("vacuum")