From b226675618b28da3651c80ef75eb0a919620cfb4 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sun, 9 Dec 2012 02:07:37 +0900 Subject: [PATCH] catch missing nids in fixIntegrity() --- anki/collection.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/anki/collection.py b/anki/collection.py index bd2df13e1..6d2227853 100644 --- a/anki/collection.py +++ b/anki/collection.py @@ -668,6 +668,15 @@ select id from notes where id not in (select distinct nid from cards)""") ngettext("Deleted %d note with no cards.", "Deleted %d notes with no cards.", cnt) % cnt) self._remNotes(ids) + # cards with missing notes + ids = self.db.list(""" +select id from cards where nid not in (select id from notes)""") + if ids: + cnt = len(ids) + problems.append( + ngettext("Deleted %d card with missing note.", + "Deleted %d cards with missing note.", cnt) % cnt) + self.remCards(ids) # tags self.tags.registerNotes() # field cache