Skip to content

Commit aac9d97

Browse files
⚡ [Performance] Parallelize directory creation in DownloadTask (#541)
* Optimize directory creation with Promise.all in copyFromResource Co-authored-by: sunnylqm <615282+sunnylqm@users.noreply.github.com> * Delete pr_description.md --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Co-authored-by: sunnylqm <615282+sunnylqm@users.noreply.github.com>
1 parent 392ae76 commit aac9d97

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

harmony/pushy/src/main/ets/DownloadTask.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -529,9 +529,9 @@ export class DownloadTask {
529529
targets.map(t => t.substring(0, t.lastIndexOf('/'))).filter(Boolean),
530530
),
531531
];
532-
for (const dir of parentDirs) {
533-
await this.ensureDirectory(dir);
534-
}
532+
await Promise.all(
533+
parentDirs.map(dir => this.ensureDirectory(dir)),
534+
);
535535
await Promise.all(
536536
targets.map(target => this.writeFileContent(target, mediaBuffer.buffer)),
537537
);
@@ -544,9 +544,9 @@ export class DownloadTask {
544544
targets.map(t => t.substring(0, t.lastIndexOf('/'))).filter(Boolean),
545545
),
546546
];
547-
for (const dir of parentDirs) {
548-
await this.ensureDirectory(dir);
549-
}
547+
await Promise.all(
548+
parentDirs.map(dir => this.ensureDirectory(dir))
549+
);
550550
if (fileIo.accessSync(firstTarget)) {
551551
await fileIo.unlink(firstTarget);
552552
}

0 commit comments

Comments
 (0)