Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
minor sync fix for fulltext
zadamae8f4ffbbe10
diff --git a/src/entities/note.js b/src/entities/note.jsindex 9253644fae..fa43dbd135 100644--- a/src/entities/note.js+++ b/src/entities/note.js@@ -107,6 +107,10 @@ class Note extends Entity {/** @returns {Promise} */async setContent(content) {+ // force updating note itself so that dateChanged is represented correctly even for the content+ this.forcedChange = true;+ await this.save();+this.content = content;const pojo = {@@ -128,10 +132,6 @@ class Note extends Entity {await sql.upsert("note_contents", "noteId", pojo);await syncTableService.addNoteContentSync(this.noteId);-- this.forcedChange = true;-- await this.save();}/** @returns {Promise} */diff --git a/src/services/note_fulltext.js b/src/services/note_fulltext.jsindex 3aa373746b..8342a5a6f3 100644--- a/src/services/note_fulltext.js+++ b/src/services/note_fulltext.js@@ -5,6 +5,11 @@ const html2plaintext = require('html2plaintext');const noteIdQueue = [];async function updateNoteFulltext(note) {+ if (!note) {+ // this might happen when note content is being synced before note itself+ return;+ }+if (note.isDeleted || note.isProtected || await note.hasLabel('archived')) {await sql.execute(`DELETEFROM note_fulltextdiff --git a/src/services/sync_update.js b/src/services/sync_update.jsindex 28636927a4..7221318da2 100644--- a/src/services/sync_update.js+++ b/src/services/sync_update.js@@ -78,10 +78,10 @@ async function updateNoteContent(entity, sourceId) {await sql.replace("note_contents", entity);await syncTableService.addNoteContentSync(entity.noteId, sourceId);-- noteFulltextService.triggerNoteFulltextUpdate(entity.noteId);});+ noteFulltextService.triggerNoteFulltextUpdate(entity.noteId);+log.info("Update/sync note content for noteId=" + entity.noteId);}}