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.
This commit is contained in:
Damien Elmes 2020-10-05 17:40:43 +10:00
parent ed3527ab52
commit 90fa38495e

View file

@ -339,7 +339,7 @@ impl SqliteStorage {
} }
pub(crate) fn optimize(&self) -> Result<()> { pub(crate) fn optimize(&self) -> Result<()> {
self.db.execute_batch("vacuum; analyze")?; self.db.execute_batch("vacuum; reindex; analyze")?;
Ok(()) Ok(())
} }