Skip to content

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

fix: only do full sync if user's key exists

thecodrr43e2d4c65c3c
diff --git a/packages/core/api/user-manager.js b/packages/core/api/user-manager.js
index 506c62242..5a015c849 100644
--- a/packages/core/api/user-manager.js
+++ b/packages/core/api/user-manager.js
@@ -228,6 +228,7 @@ class UserManager {
const user = await this.getUser();
if (!user) return;
const key = await this._storage.getCryptoKey(`_uk_@${user.email}`);
+ if (!key) return;
return { key, salt: user.salt };
}
@@ -261,6 +262,7 @@ class UserManager {
);
return JSON.parse(plainData);
} catch (e) {
+ console.error(e);
throw new Error(
`Could not get attachments encryption key. Please make sure you have Internet access. Error: ${e.message}`
);
@@ -312,9 +314,8 @@ class UserManager {
const attachmentsKey = await this.getAttachmentsKey();
data.encryptionKey = data.encryptionKey || (await this.getEncryptionKey());
-
await this._db.outbox.add(type, data, async () => {
- await this._db.sync(true, true);
+ if (data.encryptionKey) await this._db.sync(true, true);
await this._storage.deriveCryptoKey(`_uk_@${email}`, {
password: new_password,