diff --git a/anki/deck.py b/anki/deck.py index 93d44dd82..32305f572 100644 --- a/anki/deck.py +++ b/anki/deck.py @@ -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 "+ diff --git a/anki/importing/anki2.py b/anki/importing/anki2.py index 98f41e91e..db4bbdcca 100644 --- a/anki/importing/anki2.py +++ b/anki/importing/anki2.py @@ -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")