Fix invalid utf8 not being detected
- Rusqlite was returning a different error - The sort field may also contain invalid utf8
This commit is contained in:
parent
79f94d5a71
commit
ade2738458
@ -53,6 +53,15 @@ impl From<Error> for AnkiError {
|
||||
info: reason.to_owned(),
|
||||
};
|
||||
}
|
||||
} else if let Error::FromSqlConversionFailure(_, _, err) = &err {
|
||||
if let Some(_err) = err.downcast_ref::<Utf8Error>() {
|
||||
return AnkiError::DbError {
|
||||
source: DbError {
|
||||
info: "".to_string(),
|
||||
kind: DbErrorKind::Utf8,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
AnkiError::DbError {
|
||||
source: DbError {
|
||||
|
@ -150,7 +150,7 @@ impl super::SqliteStorage {
|
||||
let fixed_flds: Vec<u8> = row.get(0)?;
|
||||
let fixed_str = String::from_utf8_lossy(&fixed_flds);
|
||||
self.db.execute(
|
||||
"update notes set flds = ? where id = ?",
|
||||
"update notes set flds = ?, sfld = '' where id = ?",
|
||||
params![fixed_str, nid],
|
||||
)
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user