Skip to content

Build your personal knowledge base with Trilium Notes

fix creating note directly as protected

zadam4b41eddf4424
diff --git a/src/services/notes.js b/src/services/notes.js
index 7509956bf4..7598cde80b 100644
--- a/src/services/notes.js
+++ b/src/services/notes.js
@@ -95,7 +95,8 @@ async function createNewNote(parentNoteId, noteData) {
note.noteContent = await new NoteContent({
noteId: note.noteId,
- content: noteData.content
+ content: noteData.content,
+ isProtected: noteData.isProtected
}).save();
const branch = await new Branch({
diff --git a/src/services/protected_session.js b/src/services/protected_session.js
index cf90871aeb..d2ad3250ad 100644
--- a/src/services/protected_session.js
+++ b/src/services/protected_session.js
@@ -86,12 +86,17 @@ function decryptNoteRevision(hist) {
return;
}
- if (hist.title) {
- hist.title = dataEncryptionService.decryptString(dataKey, hist.title);
- }
+ try {
+ if (hist.title) {
+ hist.title = dataEncryptionService.decryptString(dataKey, hist.title);
+ }
- if (hist.content) {
- hist.content = dataEncryptionService.decryptString(dataKey, hist.content);
+ if (hist.content) {
+ hist.content = dataEncryptionService.decryptString(dataKey, hist.content);
+ }
+ }
+ catch (e) {
+ throw new Error(`Decryption failed for note ${hist.noteId}: ` + e.message + " " + e.stack);
}
}