mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 09:16:38 -04:00
on import make sure we update post; use static random range
This commit is contained in:
parent
c16cb6ee9b
commit
4668b1a210
2 changed files with 12 additions and 1 deletions
|
@ -248,7 +248,7 @@ crt=?, mod=?, scm=?, dty=?, usn=?, ls=?, conf=?""",
|
||||||
return ncards
|
return ncards
|
||||||
|
|
||||||
def _randPos(self):
|
def _randPos(self):
|
||||||
return random.randrange(1, self.nextID("pos", inc=False))
|
return random.randrange(1, sys.maxint)
|
||||||
|
|
||||||
def remFacts(self, ids):
|
def remFacts(self, ids):
|
||||||
self.remCards(self.db.list("select id from cards where fid in "+
|
self.remCards(self.db.list("select id from cards where fid in "+
|
||||||
|
|
|
@ -41,6 +41,7 @@ class Anki2Importer(Importer):
|
||||||
self._importFacts()
|
self._importFacts()
|
||||||
self._importCards()
|
self._importCards()
|
||||||
self._importMedia()
|
self._importMedia()
|
||||||
|
self._postImport()
|
||||||
self.dst.db.execute("vacuum")
|
self.dst.db.execute("vacuum")
|
||||||
self.dst.db.execute("analyze")
|
self.dst.db.execute("analyze")
|
||||||
|
|
||||||
|
@ -201,3 +202,13 @@ insert into revlog values (?,?,?,?,?,?,?,?,?)""", revlog)
|
||||||
|
|
||||||
def _importMedia(self):
|
def _importMedia(self):
|
||||||
self.src.media.copyTo(self.dst.media.dir())
|
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")
|
||||||
|
|
Loading…
Reference in a new issue