mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
make note cache decryption more robust - one failure will not crash the whole process, #1810
This commit is contained in:
parent
bc14c3d665
commit
2318d615bb
@ -49,8 +49,13 @@ class Note extends Entity {
|
|||||||
this.isContentAvailable = protectedSessionService.isProtectedSessionAvailable();
|
this.isContentAvailable = protectedSessionService.isProtectedSessionAvailable();
|
||||||
|
|
||||||
if (this.isContentAvailable) {
|
if (this.isContentAvailable) {
|
||||||
|
try {
|
||||||
this.title = protectedSessionService.decryptString(this.title);
|
this.title = protectedSessionService.decryptString(this.title);
|
||||||
}
|
}
|
||||||
|
catch (e) {
|
||||||
|
throw new Error(`Could not decrypt title of note ${this.noteId}: ${e.message} ${e.stack}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
this.title = "[protected]";
|
this.title = "[protected]";
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const protectedSessionService = require('../../protected_session');
|
const protectedSessionService = require('../../protected_session');
|
||||||
|
const log = require('../../log');
|
||||||
|
|
||||||
class Note {
|
class Note {
|
||||||
constructor(noteCache, row) {
|
constructor(noteCache, row) {
|
||||||
@ -416,10 +417,15 @@ class Note {
|
|||||||
|
|
||||||
decrypt() {
|
decrypt() {
|
||||||
if (this.isProtected && !this.isDecrypted && protectedSessionService.isProtectedSessionAvailable()) {
|
if (this.isProtected && !this.isDecrypted && protectedSessionService.isProtectedSessionAvailable()) {
|
||||||
|
try {
|
||||||
this.title = protectedSessionService.decryptString(this.title);
|
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}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// for logging etc
|
// for logging etc
|
||||||
|
Loading…
x
Reference in New Issue
Block a user