mirror of
https://github.com/ankitects/anki.git
synced 2025-11-07 05:07:10 -05:00
better handle invalid deck list
deleting will fail if the problem deck is the default deck - better to rename instead fixes infinite recursion errors
This commit is contained in:
parent
377bb78b88
commit
4af6aa8584
2 changed files with 12 additions and 10 deletions
|
|
@ -228,19 +228,20 @@ order by due""" % self._deckLimit(),
|
|||
parts = parts[:-1]
|
||||
return "::".join(parts)
|
||||
for deck in decks:
|
||||
# if we've already seen the exact same deck name, remove the
|
||||
# if we've already seen the exact same deck name, rename the
|
||||
# invalid duplicate and reload
|
||||
if deck['name'] in lims:
|
||||
self.col.decks.rem(deck['id'], cardsToo=False, childrenToo=True)
|
||||
deck['name'] += "1"
|
||||
self.col.decks.save(deck)
|
||||
return self.deckDueList()
|
||||
p = parent(deck['name'])
|
||||
# new
|
||||
nlim = self._deckNewLimitSingle(deck)
|
||||
if p:
|
||||
if p not in lims:
|
||||
# if parent was missing, this deck is invalid, and we
|
||||
# need to reload the deck list
|
||||
self.col.decks.rem(deck['id'], cardsToo=False, childrenToo=True)
|
||||
# if parent was missing, this deck is invalid
|
||||
deck['name'] = "recovered"
|
||||
self.col.decks.save(deck)
|
||||
return self.deckDueList()
|
||||
nlim = min(nlim, lims[p][0])
|
||||
new = self._newForDeck(deck['id'], nlim)
|
||||
|
|
|
|||
|
|
@ -218,19 +218,20 @@ order by due""" % self._deckLimit(),
|
|||
return "::".join(parts)
|
||||
childMap = self.col.decks.childMap()
|
||||
for deck in decks:
|
||||
# if we've already seen the exact same deck name, remove the
|
||||
# if we've already seen the exact same deck name, rename the
|
||||
# invalid duplicate and reload
|
||||
if deck['name'] in lims:
|
||||
self.col.decks.rem(deck['id'], cardsToo=False, childrenToo=True)
|
||||
deck['name'] += "1"
|
||||
self.col.decks.save(deck)
|
||||
return self.deckDueList()
|
||||
p = parent(deck['name'])
|
||||
# new
|
||||
nlim = self._deckNewLimitSingle(deck)
|
||||
if p:
|
||||
if p not in lims:
|
||||
# if parent was missing, this deck is invalid, and we
|
||||
# need to reload the deck list
|
||||
self.col.decks.rem(deck['id'], cardsToo=False, childrenToo=True)
|
||||
# if parent was missing, this deck is invalid
|
||||
deck['name'] = "recovered"
|
||||
self.col.decks.save(deck)
|
||||
return self.deckDueList()
|
||||
nlim = min(nlim, lims[p][0])
|
||||
new = self._newForDeck(deck['id'], nlim)
|
||||
|
|
|
|||
Loading…
Reference in a new issue