From ec9a7c37551d7ed95d4e3dd4dd9620f309dfeb1c Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Mon, 30 Nov 2009 14:31:30 +0900 Subject: [PATCH] check db integrity on backup --- anki/deck.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/anki/deck.py b/anki/deck.py index 5a1ba3198..bf2ccf670 100644 --- a/anki/deck.py +++ b/anki/deck.py @@ -3335,9 +3335,14 @@ nextFactor, reps, thinkingTime, yesCount, noCount from reviewHistory""") def backup(modified, path): """Path must not be unicode.""" - #path = os.path.join(backupDir, path) + from anki.db import sqlite if not numBackups: 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): path = os.path.abspath(path) path = path.replace("\\", "!")