Skip to content

Build your personal knowledge base with Trilium Notes

fix incorrect switch between protected/unprotected states causing content not being encrypted, fixes #510

zadama9762c5139e9
diff --git a/package-lock.json b/package-lock.json
index aefb16d338..e0d150f904 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "trilium",
- "version": "0.31.3",
+ "version": "0.31.4",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
diff --git a/src/services/notes.js b/src/services/notes.js
index 0d5ee7cfac..ed9451fb74 100644
--- a/src/services/notes.js
+++ b/src/services/notes.js
@@ -186,8 +186,13 @@ async function protectNoteRecursively(note, protect) {
async function protectNote(note, protect) {
if (protect !== note.isProtected) {
+ const content = await note.getContent();
+
note.isProtected = protect;
+ // this will force de/encryption
+ await note.setContent(content);
+
await note.save();
}