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
more robust handling of sync error, fixes #830
zadama6cd25071ea6
diff --git a/.idea/.gitignore b/.idea/.gitignoreindex c0f9e196c1..2102c8715d 100644--- a/.idea/.gitignore+++ b/.idea/.gitignore@@ -2,4 +2,5 @@/workspace.xml# Datasource local storage ignored files-/dataSources.local.xml\ No newline at end of file+/dataSources.local.xml+/dataSources/diff --git a/src/services/notes.js b/src/services/notes.jsindex dacf40d628..2715a4eb5c 100644--- a/src/services/notes.js+++ b/src/services/notes.js@@ -277,7 +277,7 @@ async function saveLinks(note, content) {}const foundLinks = [];-console.log("Scanning", content);+if (note.type === 'text') {content = findImageLinks(content, foundLinks);content = findInternalLinks(content, foundLinks);diff --git a/src/services/ws.js b/src/services/ws.jsindex 1a1a45831a..b4703dfc34 100644--- a/src/services/ws.js+++ b/src/services/ws.js@@ -71,22 +71,36 @@ function sendMessageToAllClients(message) {}}+async function fillInAdditionalProperties(sync) {throw new Error("AAA");+ // fill in some extra data needed by the frontend+ if (sync.entityName === 'attributes') {+ sync.noteId = await sql.getValue(`SELECT noteId+ FROM attributes+ WHERE attributeId = ?`, [sync.entityId]);+ } else if (sync.entityName === 'note_revisions') {+ sync.noteId = await sql.getValue(`SELECT noteId+ FROM note_revisions+ WHERE noteRevisionId = ?`, [sync.entityId]);+ } else if (sync.entityName === 'branches') {+ const {noteId, parentNoteId} = await sql.getRow(`SELECT noteId, parentNoteId+ FROM branches+ WHERE branchId = ?`, [sync.entityId]);++ sync.noteId = noteId;+ sync.parentNoteId = parentNoteId;+ }+}+async function sendPing(client) {const syncData = require('./sync_table').getEntitySyncsNewerThan(lastAcceptedSyncIds[client.id]);for (const sync of syncData) {- // fill in some extra data needed by the frontend- if (sync.entityName === 'attributes') {- sync.noteId = await sql.getValue(`SELECT noteId FROM attributes WHERE attributeId = ?`, [sync.entityId]);+ try {+ await fillInAdditionalProperties(sync);}- else if (sync.entityName === 'note_revisions') {- sync.noteId = await sql.getValue(`SELECT noteId FROM note_revisions WHERE noteRevisionId = ?`, [sync.entityId]);- }- else if (sync.entityName === 'branches') {- const {noteId, parentNoteId} = await sql.getRow(`SELECT noteId, parentNoteId FROM branches WHERE branchId = ?`, [sync.entityId]);-- sync.noteId = noteId;- sync.parentNoteId = parentNoteId;+ catch (e) {+ log.error("Could not fill additional properties for sync " + JSON.stringify(sync)+ + " because of error: " + e.message + ": " + e.stack);}}