mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
Fix invalid utf-8 in tags
This commit is contained in:
parent
a1f4bcb3cb
commit
add6f6f62f
1 changed files with 5 additions and 3 deletions
|
@ -145,14 +145,16 @@ impl super::SqliteStorage {
|
||||||
pub(crate) fn fix_invalid_utf8_in_note(&self, nid: NoteId) -> Result<()> {
|
pub(crate) fn fix_invalid_utf8_in_note(&self, nid: NoteId) -> Result<()> {
|
||||||
self.db
|
self.db
|
||||||
.query_row(
|
.query_row(
|
||||||
"select cast(flds as blob) from notes where id=?",
|
"select cast(flds as blob), cast(tags as blob) from notes where id=?",
|
||||||
[nid],
|
[nid],
|
||||||
|row| {
|
|row| {
|
||||||
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);
|
||||||
|
let fixed_tags: Vec<u8> = row.get(1)?;
|
||||||
|
let fixed_tags = String::from_utf8_lossy(&fixed_tags);
|
||||||
self.db.execute(
|
self.db.execute(
|
||||||
"update notes set flds = ?, sfld = '' where id = ?",
|
"update notes set flds = ?, sfld = '', tags = ? where id = ?",
|
||||||
params![fixed_str, nid],
|
params![fixed_str, fixed_tags, nid],
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue