mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 23:12:21 -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):
|
def cardCount(self):
|
||||||
return self.db.scalar("select count() from cards")
|
return self.db.scalar("select count() from cards")
|
||||||
|
|
||||||
def remCards(self, ids):
|
def remCards(self, ids, notes=True):
|
||||||
"Bulk delete cards by ID."
|
"Bulk delete cards by ID."
|
||||||
if not ids:
|
if not ids:
|
||||||
return
|
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 cards where id in "+sids)
|
||||||
self.db.execute("delete from revlog where cid in "+sids)
|
self.db.execute("delete from revlog where cid in "+sids)
|
||||||
# then notes
|
# then notes
|
||||||
|
if not notes:
|
||||||
|
return
|
||||||
nids = self.db.list("""
|
nids = self.db.list("""
|
||||||
select id from notes where id in %s and id not in (select nid from cards)""" %
|
select id from notes where id in %s and id not in (select nid from cards)""" %
|
||||||
ids2str(nids))
|
ids2str(nids))
|
||||||
|
|
|
@ -311,7 +311,7 @@ from notes where %s""" % d)
|
||||||
# notes first, so we don't end up with duplicate graves
|
# notes first, so we don't end up with duplicate graves
|
||||||
self.col._remNotes(graves['notes'])
|
self.col._remNotes(graves['notes'])
|
||||||
# then cards
|
# then cards
|
||||||
self.col.remCards(graves['cards'])
|
self.col.remCards(graves['cards'], notes=False)
|
||||||
# and decks
|
# and decks
|
||||||
for oid in graves['decks']:
|
for oid in graves['decks']:
|
||||||
self.col.decks.rem(oid, childrenToo=False)
|
self.col.decks.rem(oid, childrenToo=False)
|
||||||
|
|
Loading…
Reference in a new issue