From 1425379d41d458e062a20cabd195dea8ae3939a2 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sat, 9 Jan 2021 10:17:47 +1000 Subject: [PATCH] drop basicCheck() It can considerably slow down syncing on large collections --- pylib/anki/collection.py | 31 ------------------------------- qt/aqt/sync.py | 4 ---- 2 files changed, 35 deletions(-) diff --git a/pylib/anki/collection.py b/pylib/anki/collection.py index 6ac769814..463b7d30f 100644 --- a/pylib/anki/collection.py +++ b/pylib/anki/collection.py @@ -632,37 +632,6 @@ table.review-log {{ {revlog_style} }} # DB maintenance ########################################################################## - def basicCheck(self) -> bool: - "Basic integrity check for syncing. True if ok." - # cards without notes - if self.db.scalar( - """ -select 1 from cards where nid not in (select id from notes) limit 1""" - ): - return False - # notes without cards or models - if self.db.scalar( - """ -select 1 from notes where id not in (select distinct nid from cards) -or mid not in %s limit 1""" - % ids2str(self.models.ids()) - ): - return False - # invalid ords - for m in self.models.all(): - # ignore clozes - if m["type"] != MODEL_STD: - continue - if self.db.scalar( - """ -select 1 from cards where ord not in %s and nid in ( -select id from notes where mid = ?) limit 1""" - % ids2str([t["ord"] for t in m["tmpls"]]), - m["id"], - ): - return False - return True - def fixIntegrity(self) -> Tuple[str, bool]: """Fix possible problems and rebuild caches. diff --git a/qt/aqt/sync.py b/qt/aqt/sync.py index a4ce2512c..691fde1f4 100644 --- a/qt/aqt/sync.py +++ b/qt/aqt/sync.py @@ -122,10 +122,6 @@ def sync_collection(mw: aqt.main.AnkiQt, on_done: Callable[[], None]) -> None: else: full_sync(mw, out, on_done) - if not mw.col.basicCheck(): - showWarning("Please use Tools>Check Database") - return on_done() - mw.col.save(trx=False) mw.taskman.with_progress( lambda: mw.col.backend.sync_collection(auth),