Skip to content

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

fix: crash when extracting attachments from notes

thecodrrdb87d05b3ee0
diff --git a/packages/core/api/sync/index.js b/packages/core/api/sync/index.js
index 86c89dae9..3208e2306 100644
--- a/packages/core/api/sync/index.js
+++ b/packages/core/api/sync/index.js
@@ -153,7 +153,7 @@ export default class Sync {
async _uploadAttachments(token) {
const attachments = this._db.attachments.pending;
- console.log("Uploading attachments", attachments);
+ console.log("Uploading attachments", this._db.attachments.pending);
for (let attachment of attachments) {
const { hash } = attachment.metadata;
const url = await this._getPresignedURL(hash, token, "PUT");
diff --git a/packages/core/collections/attachments.js b/packages/core/collections/attachments.js
index a18eb023f..a61a97cb4 100644
--- a/packages/core/collections/attachments.js
+++ b/packages/core/collections/attachments.js
@@ -122,7 +122,11 @@ export default class Attachments extends Collection {
async save(data, type) {
await this._initEncryptionKey();
- await this._db.fs.writeEncrypted(null, { data, type, key: this.key });
+ return await this._db.fs.writeEncrypted(null, {
+ data,
+ type,
+ key: this.key,
+ });
}
get pending() {
diff --git a/packages/core/content-types/tiny.js b/packages/core/content-types/tiny.js
index bdd7576a8..1b74cc6f3 100644
--- a/packages/core/content-types/tiny.js
+++ b/packages/core/content-types/tiny.js
@@ -106,7 +106,7 @@ class Tiny {
const type =
getDatasetAttribute(attachment, "mime") || mime || "image/jpeg";
const metadata = await store(data, "base64");
- setDatasetAttribute("hash", metadata.hash);
+ setDatasetAttribute(attachment, "hash", metadata.hash);
attachments.push({
type,