From add6f6f62f51a8f0b846bae49972b7fbebf802e2 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Wed, 27 Sep 2023 10:06:31 +1000 Subject: [PATCH] Fix invalid utf-8 in tags --- rslib/src/storage/note/mod.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/rslib/src/storage/note/mod.rs b/rslib/src/storage/note/mod.rs index c5b16df9c..b9798f26f 100644 --- a/rslib/src/storage/note/mod.rs +++ b/rslib/src/storage/note/mod.rs @@ -145,14 +145,16 @@ impl super::SqliteStorage { pub(crate) fn fix_invalid_utf8_in_note(&self, nid: NoteId) -> Result<()> { self.db .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], |row| { let fixed_flds: Vec = row.get(0)?; let fixed_str = String::from_utf8_lossy(&fixed_flds); + let fixed_tags: Vec = row.get(1)?; + let fixed_tags = String::from_utf8_lossy(&fixed_tags); self.db.execute( - "update notes set flds = ?, sfld = '' where id = ?", - params![fixed_str, nid], + "update notes set flds = ?, sfld = '', tags = ? where id = ?", + params![fixed_str, fixed_tags, nid], ) }, )