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
make note cache decryption more robust - one failure will not crash the whole process, #1810
zadam2318d615bbe3
diff --git a/src/entities/note.js b/src/entities/note.jsindex 78173c5827..07fcd644dc 100644--- a/src/entities/note.js+++ b/src/entities/note.js@@ -49,7 +49,12 @@ class Note extends Entity {this.isContentAvailable = protectedSessionService.isProtectedSessionAvailable();if (this.isContentAvailable) {- this.title = protectedSessionService.decryptString(this.title);+ try {+ this.title = protectedSessionService.decryptString(this.title);+ }+ catch (e) {+ throw new Error(`Could not decrypt title of note ${this.noteId}: ${e.message} ${e.stack}`)+ }}else {this.title = "[protected]";diff --git a/src/services/note_cache/entities/note.js b/src/services/note_cache/entities/note.jsindex 3adef31485..30831ebdb7 100644--- a/src/services/note_cache/entities/note.js+++ b/src/services/note_cache/entities/note.js@@ -1,6 +1,7 @@"use strict";const protectedSessionService = require('../../protected_session');+const log = require('../../log');class Note {constructor(noteCache, row) {@@ -416,9 +417,14 @@ class Note {decrypt() {if (this.isProtected && !this.isDecrypted && protectedSessionService.isProtectedSessionAvailable()) {- this.title = protectedSessionService.decryptString(this.title);+ try {+ this.title = protectedSessionService.decryptString(this.title);- this.isDecrypted = true;+ this.isDecrypted = true;+ }+ catch (e) {+ log.error(`Could not decrypt note ${this.noteId}: ${e.message} ${e.stack}`);+ }}}