Skip to content

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

core: fix progress when bulk downloading files

Abdullah Atta69cb24149d67
diff --git a/packages/core/src/database/fs.ts b/packages/core/src/database/fs.ts
index eefd85c26..bb2f24e97 100644
--- a/packages/core/src/database/fs.ts
+++ b/packages/core/src/database/fs.ts
@@ -68,7 +68,18 @@ export class FileStorage {
this.groups.downloads.set(groupId, group);
for (const file of files as QueueItem[]) {
- if (!group.has(file.filename)) continue;
+ current++;
+ if (!group.has(file.filename)) {
+ EV.publish(EVENTS.fileDownloaded, {
+ success: false,
+ groupId,
+ filename: file.filename,
+ eventData,
+ current,
+ total
+ });
+ continue;
+ }
const download = this.downloads.get(file.filename);
if (download && download.operation) {
@@ -82,12 +93,13 @@ export class FileStorage {
const { filename, chunkSize } = file;
if (await this.exists(filename)) {
- current++;
EV.publish(EVENTS.fileDownloaded, {
success: true,
groupId,
filename,
- eventData
+ eventData,
+ current,
+ total
});
continue;
}
@@ -119,7 +131,7 @@ export class FileStorage {
EV.publish(EVENTS.fileDownloaded, {
success: result,
total,
- current: ++current,
+ current,
groupId,
filename,
eventData