make note cache decryption more robust - one failure will not crash the whole process, #1810

This commit is contained in:
zadam 2021-04-03 21:48:16 +02:00
parent bc14c3d665
commit 2318d615bb
2 changed files with 14 additions and 3 deletions

View file

@ -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]";

View file

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