From 76ef8e3ba865c0bcca8eead77e2883b17de578fd Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 29 Mar 2026 10:33:36 +0000 Subject: [PATCH] perf(harmony): parallelize file copy and delete operations in DownloadTask File deletions and copies in `doPatchFromPpk` were previously executed sequentially using `await` in loops. This commit refactors these operations to use `Promise.all()`, allowing them to execute concurrently and improving overall patch application performance. Co-authored-by: sunnylqm <615282+sunnylqm@users.noreply.github.com> --- harmony/pushy/src/main/ets/DownloadTask.ts | 38 ++++++++++++---------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/harmony/pushy/src/main/ets/DownloadTask.ts b/harmony/pushy/src/main/ets/DownloadTask.ts index 72905c88..ea391770 100644 --- a/harmony/pushy/src/main/ets/DownloadTask.ts +++ b/harmony/pushy/src/main/ets/DownloadTask.ts @@ -350,23 +350,27 @@ export class DownloadTask { ); const { copies, deletes } = obj; - for (const [to, from] of Object.entries(copies)) { - await fileIo - .copyFile( - `${params.originDirectory}/${from}`, - `${params.unzipDirectory}/${to}`, - ) - .catch(error => { - console.error('copy error:', error); - }); - } - for (const fileToDelete of Object.keys(deletes)) { - await fileIo - .unlink(`${params.unzipDirectory}/${fileToDelete}`) - .catch(error => { - console.error('delete error:', error); - }); - } + await Promise.all( + Object.entries(copies as Record).map(([to, from]) => + fileIo + .copyFile( + `${params.originDirectory}/${from}`, + `${params.unzipDirectory}/${to}`, + ) + .catch(error => { + console.error('copy error:', error); + }), + ), + ); + await Promise.all( + Object.keys(deletes as Record).map(fileToDelete => + fileIo + .unlink(`${params.unzipDirectory}/${fileToDelete}`) + .catch(error => { + console.error('delete error:', error); + }), + ), + ); continue; } if (fn === 'bundle.harmony.js.patch') {