fix: crash when extracting attachments from notes

This commit is contained in:
thecodrr
2021-09-23 10:57:55 +05:00
parent 052fca4f42
commit db87d05b3e
3 changed files with 7 additions and 3 deletions

View File

@@ -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");

View File

@@ -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() {

View File

@@ -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,