mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
don't upgrade clozes while iterating
This commit is contained in:
parent
5cbe93b63d
commit
fe0e227325
1 changed files with 6 additions and 2 deletions
|
@ -82,12 +82,15 @@ def _upgrade(col, ver):
|
||||||
col.decks.save(d)
|
col.decks.save(d)
|
||||||
if ver < 4:
|
if ver < 4:
|
||||||
col.modSchema()
|
col.modSchema()
|
||||||
|
clozes = []
|
||||||
for m in col.models.all():
|
for m in col.models.all():
|
||||||
if not "{{cloze:" in m['tmpls'][0]['qfmt']:
|
if not "{{cloze:" in m['tmpls'][0]['qfmt']:
|
||||||
m['type'] = MODEL_STD
|
m['type'] = MODEL_STD
|
||||||
else:
|
|
||||||
_upgradeClozeModel(col, m)
|
|
||||||
col.models.save(m)
|
col.models.save(m)
|
||||||
|
else:
|
||||||
|
clozes.append(m)
|
||||||
|
for m in clozes:
|
||||||
|
_upgradeClozeModel(col, m)
|
||||||
col.db.execute("update col set ver = 4")
|
col.db.execute("update col set ver = 4")
|
||||||
|
|
||||||
def _upgradeClozeModel(col, m):
|
def _upgradeClozeModel(col, m):
|
||||||
|
@ -106,6 +109,7 @@ def _upgradeClozeModel(col, m):
|
||||||
col.models.remTemplate(m, r)
|
col.models.remTemplate(m, r)
|
||||||
del m['tmpls'][1:]
|
del m['tmpls'][1:]
|
||||||
col.models._updateTemplOrds(m)
|
col.models._updateTemplOrds(m)
|
||||||
|
col.models.save(m)
|
||||||
|
|
||||||
# Creating a new collection
|
# Creating a new collection
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
Loading…
Reference in a new issue