mirror of
https://github.com/ankitects/anki.git
synced 2025-11-06 20:57:13 -05:00
fix deck syncing problems
- delete only the decks with graves, not any children - make sure we log the deletion even if the deck didn't exist
This commit is contained in:
parent
f9ed0d657c
commit
b89dde97a8
2 changed files with 9 additions and 5 deletions
|
|
@ -114,12 +114,17 @@ class DeckManager(object):
|
|||
self.maybeAddToActive()
|
||||
return int(id)
|
||||
|
||||
def rem(self, did, cardsToo=False):
|
||||
def rem(self, did, cardsToo=False, childrenToo=True):
|
||||
"Remove the deck. If cardsToo, delete any cards inside."
|
||||
assert str(did) != '1'
|
||||
# log the removal regardless of whether we have the deck or not
|
||||
self.col._logRem([did], REM_DECK)
|
||||
# do nothing else if doesn't exist
|
||||
if not str(did) in self.decks:
|
||||
return
|
||||
# delete children first
|
||||
if childrenToo:
|
||||
# we don't want to delete children when syncing
|
||||
for name, id in self.children(did):
|
||||
self.rem(id, cardsToo)
|
||||
# delete cards too?
|
||||
|
|
@ -127,7 +132,6 @@ class DeckManager(object):
|
|||
self.col.remCards(self.cids(did))
|
||||
# delete the deck and add a grave
|
||||
del self.decks[str(did)]
|
||||
self.col._logRem([did], REM_DECK)
|
||||
# ensure we have an active deck
|
||||
if did in self.active():
|
||||
self.select(int(self.decks.keys()[0]))
|
||||
|
|
|
|||
|
|
@ -263,7 +263,7 @@ from notes where %s""" % d)
|
|||
self.col.remCards(graves['cards'])
|
||||
# and decks
|
||||
for oid in graves['decks']:
|
||||
self.col.decks.rem(oid)
|
||||
self.col.decks.rem(oid, childrenToo=False)
|
||||
self.col.server = wasServer
|
||||
|
||||
# Models
|
||||
|
|
|
|||
Loading…
Reference in a new issue