on import make sure we update post; use static random range

This commit is contained in:
Damien Elmes 2011-10-26 06:24:14 +09:00
parent c16cb6ee9b
commit 4668b1a210
2 changed files with 12 additions and 1 deletions

View file

@ -248,7 +248,7 @@ crt=?, mod=?, scm=?, dty=?, usn=?, ls=?, conf=?""",
return ncards
def _randPos(self):
return random.randrange(1, self.nextID("pos", inc=False))
return random.randrange(1, sys.maxint)
def remFacts(self, ids):
self.remCards(self.db.list("select id from cards where fid in "+

View file

@ -41,6 +41,7 @@ class Anki2Importer(Importer):
self._importFacts()
self._importCards()
self._importMedia()
self._postImport()
self.dst.db.execute("vacuum")
self.dst.db.execute("analyze")
@ -201,3 +202,13 @@ insert into revlog values (?,?,?,?,?,?,?,?,?)""", revlog)
def _importMedia(self):
self.src.media.copyTo(self.dst.media.dir())
# Post-import cleanup
######################################################################
# fixme: we could be handling new card order more elegantly on import
def _postImport(self):
if self.needCards:
# make sure new position is correct
self.dst.conf['nextPos'] = self.dst.db.scalar(
"select max(due)+1 from cards where type = 0")