mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
perform basic check prior to syncing
This commit is contained in:
parent
d2535fd6cb
commit
e913c75fd7
2 changed files with 14 additions and 6 deletions
11
anki/sync.py
11
anki/sync.py
|
@ -107,6 +107,9 @@ class Syncer(object):
|
|||
elif lscm != rscm:
|
||||
return "fullSync"
|
||||
self.lnewer = self.lmod > self.rmod
|
||||
# step 1.5: check collection is valid
|
||||
if not self.col.basicCheck():
|
||||
return "basicCheckFailed"
|
||||
# step 2: deletions
|
||||
runHook("sync", "meta")
|
||||
lrem = self.removed()
|
||||
|
@ -182,12 +185,8 @@ class Syncer(object):
|
|||
self.prepareToChunk()
|
||||
|
||||
def sanityCheck(self):
|
||||
if self.col.db.scalar("""
|
||||
select count() from cards where nid not in (select id from notes)"""):
|
||||
return "missing notes"
|
||||
if self.col.db.scalar("""
|
||||
select count() from notes where id not in (select distinct nid from cards)"""):
|
||||
return "missing cards"
|
||||
if not self.col.basicCheck():
|
||||
return "failed basic check"
|
||||
for t in "cards", "notes", "revlog", "graves":
|
||||
if self.col.db.scalar(
|
||||
"select count() from %s where usn = -1" % t):
|
||||
|
|
|
@ -114,6 +114,8 @@ Please visit AnkiWeb, upgrade your deck, then try again."""))
|
|||
self._rewriteError(args[0]))
|
||||
elif evt == "clockOff":
|
||||
self._clockOff()
|
||||
elif evt == "basicCheckFailed":
|
||||
self._basicCheckFailed()
|
||||
elif evt == "noChanges":
|
||||
pass
|
||||
elif evt == "fullSync":
|
||||
|
@ -237,6 +239,11 @@ automatically."""),
|
|||
Syncing requires the clock on your computer to be set correctly. Please \
|
||||
fix the clock and try again."""))
|
||||
|
||||
def _basicCheckFailed(self):
|
||||
showWarning(_("""\
|
||||
Your collection is in an inconsistent state. Please run Tools>\
|
||||
Maintenance>Check Database."""))
|
||||
|
||||
def badUserPass(self):
|
||||
aqt.preferences.Preferences(self, self.pm.profile).dialog.tabWidget.\
|
||||
setCurrentIndex(1)
|
||||
|
@ -330,6 +337,8 @@ class SyncThread(QThread):
|
|||
return self.fireEvent("badAuth")
|
||||
elif ret == "clockOff":
|
||||
return self.fireEvent("clockOff")
|
||||
elif ret == "basicCheckFailed":
|
||||
return self.fireEvent("basicCheckFailed")
|
||||
# note mediaUSN for later
|
||||
self.mediaUsn = self.client.mediaUsn
|
||||
# full sync?
|
||||
|
|
Loading…
Reference in a new issue