mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 01:06:35 -04:00
drop basicCheck()
It can considerably slow down syncing on large collections
This commit is contained in:
parent
f6c1a91674
commit
1425379d41
2 changed files with 0 additions and 35 deletions
|
@ -632,37 +632,6 @@ table.review-log {{ {revlog_style} }}
|
||||||
# DB maintenance
|
# 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]:
|
def fixIntegrity(self) -> Tuple[str, bool]:
|
||||||
"""Fix possible problems and rebuild caches.
|
"""Fix possible problems and rebuild caches.
|
||||||
|
|
||||||
|
|
|
@ -122,10 +122,6 @@ def sync_collection(mw: aqt.main.AnkiQt, on_done: Callable[[], None]) -> None:
|
||||||
else:
|
else:
|
||||||
full_sync(mw, out, on_done)
|
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.col.save(trx=False)
|
||||||
mw.taskman.with_progress(
|
mw.taskman.with_progress(
|
||||||
lambda: mw.col.backend.sync_collection(auth),
|
lambda: mw.col.backend.sync_collection(auth),
|
||||||
|
|
Loading…
Reference in a new issue