Skip to content

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

fix: exception when mergin locked notes

thecodrr1113c5cfcd31
diff --git a/packages/core/api/sync/merger.js b/packages/core/api/sync/merger.js
index 10fdd6305..b0cdae3a3 100644
--- a/packages/core/api/sync/merger.js
+++ b/packages/core/api/sync/merger.js
@@ -109,20 +109,22 @@ class Merger {
(id) => this._db.content.raw(id),
(item) => this._db.content.add(item),
async (local, remote) => {
+ let note = this._db.notes.note(local.noteId);
+ if (!note || !note.data) return;
+ note = note.data;
+
// if hashes are equal do nothing
if (
- !remote ||
- !local ||
- !remote.data ||
- remote.data === "undefined" || //TODO not sure about this
- SparkMD5.hash(local.data) === SparkMD5.hash(remote.data)
+ !note.locked &&
+ (!remote ||
+ !local ||
+ !local.data ||
+ !remote.data ||
+ remote.data === "undefined" || //TODO not sure about this
+ SparkMD5.hash(local.data) === SparkMD5.hash(remote.data))
)
return;
- let note = this._db.notes.note(local.noteId);
- if (!note || !note.data) return;
- note = note.data;
-
if (remote.deleted || local.deleted || note.locked) {
// if note is locked or content is deleted we keep the most recent version.
if (remote.dateEdited > local.dateEdited)