mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 07:22:23 -04:00
don't delete orphaned notes on sync
Fields are synced later, and they may prevent a note from becoming orphaned
This commit is contained in:
parent
74af374720
commit
c5abb535ed
2 changed files with 4 additions and 2 deletions
|
@ -394,7 +394,7 @@ insert into cards values (?,?,?,?,?,?,0,0,?,0,0,0,0,0,0,0,0,"")""",
|
|||
def cardCount(self):
|
||||
return self.db.scalar("select count() from cards")
|
||||
|
||||
def remCards(self, ids):
|
||||
def remCards(self, ids, notes=True):
|
||||
"Bulk delete cards by ID."
|
||||
if not ids:
|
||||
return
|
||||
|
@ -405,6 +405,8 @@ insert into cards values (?,?,?,?,?,?,0,0,?,0,0,0,0,0,0,0,0,"")""",
|
|||
self.db.execute("delete from cards where id in "+sids)
|
||||
self.db.execute("delete from revlog where cid in "+sids)
|
||||
# then notes
|
||||
if not notes:
|
||||
return
|
||||
nids = self.db.list("""
|
||||
select id from notes where id in %s and id not in (select nid from cards)""" %
|
||||
ids2str(nids))
|
||||
|
|
|
@ -311,7 +311,7 @@ from notes where %s""" % d)
|
|||
# notes first, so we don't end up with duplicate graves
|
||||
self.col._remNotes(graves['notes'])
|
||||
# then cards
|
||||
self.col.remCards(graves['cards'])
|
||||
self.col.remCards(graves['cards'], notes=False)
|
||||
# and decks
|
||||
for oid in graves['decks']:
|
||||
self.col.decks.rem(oid, childrenToo=False)
|
||||
|
|
Loading…
Reference in a new issue