Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix: don't lock empty note

thecodrrd173bb1fa75c
diff --git a/packages/core/api/vault.js b/packages/core/api/vault.js
index 8df12be7d..b6d83cf7a 100644
--- a/packages/core/api/vault.js
+++ b/packages/core/api/vault.js
@@ -233,13 +233,15 @@ export default class Vault {
/** @private */
async _lockNote(note, password) {
- let { id, content: { type, data } = {}, contentId, sessionId } = note;
+ let { id, content: { type, data } = {}, sessionId } = note;
+
+ note = this._db.notes.note(id).data;
+ const contentId = note.contentId;
+ if (!contentId) throw new Error("Cannot lock note because it is empty.");
// Case: when note is being newly locked
- if (!data || !type || !contentId) {
- note = this._db.notes.note(id).data;
+ if (!data || !type) {
if (note.locked) return;
- contentId = note.contentId;
let content = await this._db.content.raw(contentId, false);
// NOTE:
// At this point, the note already has all the attachments extracted