Skip to content

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

feat: better error on upload att. failed

thecodrr621c4373edc8
diff --git a/packages/core/api/sync/index.js b/packages/core/api/sync/index.js
index d774b0353..a40f53bf7 100644
--- a/packages/core/api/sync/index.js
+++ b/packages/core/api/sync/index.js
@@ -186,22 +186,23 @@ export default class Sync {
async _uploadAttachments() {
const attachments = this._db.attachments.pending;
- try {
- for (var i = 0; i < attachments.length; ++i) {
- const attachment = attachments[i];
- const { hash } = attachment.metadata;
- sendAttachmentsProgressEvent("upload", hash, attachments.length, i);
+ for (var i = 0; i < attachments.length; ++i) {
+ const attachment = attachments[i];
+ const { hash, filename } = attachment.metadata;
+ sendAttachmentsProgressEvent("upload", hash, attachments.length, i);
+ try {
const isUploaded = await this._db.fs.uploadFile(hash, hash);
if (!isUploaded) throw new Error("Failed to upload file.");
await this._db.attachments.markAsUploaded(attachment.id);
+ } catch (e) {
+ throw new Error(
+ `Failed to upload the following attachment: "${filename}". Please try attaching this file again. (Reference error: ${e.message})`
+ );
}
- } catch (e) {
- throw new Error("Failed to upload attachments. Error: " + e.message);
- } finally {
- sendAttachmentsProgressEvent("upload", null, attachments.length);
}
+ sendAttachmentsProgressEvent("upload", null, attachments.length);
}
async _performChecks() {