mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
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
2 changed files with 10 additions and 1 deletions
|
@ -53,6 +53,15 @@ impl From<Error> for AnkiError {
|
||||||
info: reason.to_owned(),
|
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 {
|
AnkiError::DbError {
|
||||||
source: DbError {
|
source: DbError {
|
||||||
|
|
|
@ -150,7 +150,7 @@ impl super::SqliteStorage {
|
||||||
let fixed_flds: Vec<u8> = row.get(0)?;
|
let fixed_flds: Vec<u8> = row.get(0)?;
|
||||||
let fixed_str = String::from_utf8_lossy(&fixed_flds);
|
let fixed_str = String::from_utf8_lossy(&fixed_flds);
|
||||||
self.db.execute(
|
self.db.execute(
|
||||||
"update notes set flds = ? where id = ?",
|
"update notes set flds = ?, sfld = '' where id = ?",
|
||||||
params![fixed_str, nid],
|
params![fixed_str, nid],
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue