catch invalid card ordinals in DB check

https://forums.ankiweb.net/t/error-corrupted-note/10976
This commit is contained in:
Damien Elmes 2021-06-28 19:05:01 +10:00
parent 8942677c4b
commit e3c9808b79
2 changed files with 9 additions and 0 deletions

View File

@ -0,0 +1,5 @@
UPDATE cards
SET ord = max(0, min(30000, ord)),
mod = ?1,
usn = ?2
WHERE ord != max(0, min(30000, ord))

View File

@ -286,6 +286,10 @@ impl super::SqliteStorage {
.db
.prepare(include_str!("fix_ivl.sql"))?
.execute(params![mtime, usn])?;
other_cnt += self
.db
.prepare(include_str!("fix_ordinal.sql"))?
.execute(params![mtime, usn])?;
Ok((new_cnt, other_cnt))
}