minor sync fix for fulltext

This commit is contained in:
zadam 2019-04-11 21:44:35 +02:00
parent 896776516b
commit ae8f4ffbbe
3 changed files with 11 additions and 6 deletions

View File

@ -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} */

View File

@ -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(`DELETE
FROM note_fulltext

View File

@ -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);
}
}