check db integrity on backup

This commit is contained in:
Damien Elmes 2009-11-30 14:31:30 +09:00
parent 6a8c19a889
commit ec9a7c3755

View file

@ -3335,9 +3335,14 @@ nextFactor, reps, thinkingTime, yesCount, noCount from reviewHistory""")
def backup(modified, path): def backup(modified, path):
"""Path must not be unicode.""" """Path must not be unicode."""
#path = os.path.join(backupDir, path) from anki.db import sqlite
if not numBackups: if not numBackups:
return return
# check integrity
con = sqlite.connect(path)
if not con.execute("pragma integrity_check").fetchone() == ("ok",):
raise DeckAccessError(_("Deck is corrupt."), type="corrupt")
con.close()
def escape(path): def escape(path):
path = os.path.abspath(path) path = os.path.abspath(path)
path = path.replace("\\", "!") path = path.replace("\\", "!")