diff --git a/harmony/pushy/src/main/ets/DownloadTask.ts b/harmony/pushy/src/main/ets/DownloadTask.ts index 9ef44254..4fdafffc 100644 --- a/harmony/pushy/src/main/ets/DownloadTask.ts +++ b/harmony/pushy/src/main/ets/DownloadTask.ts @@ -526,9 +526,9 @@ export class DownloadTask { targets.map(t => t.substring(0, t.lastIndexOf('/'))).filter(Boolean), ), ]; - for (const dir of parentDirs) { - await this.ensureDirectory(dir); - } + await Promise.all( + parentDirs.map(dir => this.ensureDirectory(dir)), + ); await Promise.all( targets.map(target => this.writeFileContent(target, mediaBuffer.buffer)), ); @@ -541,9 +541,9 @@ export class DownloadTask { targets.map(t => t.substring(0, t.lastIndexOf('/'))).filter(Boolean), ), ]; - for (const dir of parentDirs) { - await this.ensureDirectory(dir); - } + await Promise.all( + parentDirs.map(dir => this.ensureDirectory(dir)) + ); if (fileIo.accessSync(firstTarget)) { await fileIo.unlink(firstTarget); }