From 90fa38495eca4ab97691774f186a6a21ec047323 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Mon, 5 Oct 2020 17:40:43 +1000 Subject: [PATCH] reindex when checking database Came across a user with a corrupt index: sqlite> pragma integrity_check; integrity_check = wrong # of entries in index ix_revlog_cid integrity_check = wrong # of entries in index ix_cards_sched This is not picked up by a quick check, and a vacuum does not fix it, but a reindex does. AnkiWeb currently performs a full check when a file is uploaded to it, so this was leading to "corrupt" to show up when syncing the collection, with a local DB check not reporting/fixing the issue. --- rslib/src/storage/sqlite.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rslib/src/storage/sqlite.rs b/rslib/src/storage/sqlite.rs index 36dc0c05b..31b142888 100644 --- a/rslib/src/storage/sqlite.rs +++ b/rslib/src/storage/sqlite.rs @@ -339,7 +339,7 @@ impl SqliteStorage { } pub(crate) fn optimize(&self) -> Result<()> { - self.db.execute_batch("vacuum; analyze")?; + self.db.execute_batch("vacuum; reindex; analyze")?; Ok(()) }