Commit f90df7b
⚡ Parallelize sequential I/O and mitigate race conditions in harmony/pushy/DownloadTask.ts
Optimized multiple I/O-bound loops in the HarmonyOS implementation to use `Promise.all` instead of sequential `await` calls. This significantly reduces total execution time for directory listing, manifest reading, and resource copying.
To ensure robustness during parallel operations:
- Hardened `ensureDirectory` to be idempotent by handling concurrent directory creation errors.
- Refactored `copyFromResource` to calculate unique parent directories and pre-create them sequentially before initiating parallel fan-out writes/copies.
Key improvements:
- `listEntryNames`: Parallelized `fileIo.stat` calls.
- `doPatchFromApp`/`doPatchFromPpk`: Parallelized `listEntryNames` and `readManifestArrays`.
- `copyFromResource`: Parallelized destination writes (media) and copies (raw resources) with race condition mitigation.
Co-authored-by: sunnylqm <615282+sunnylqm@users.noreply.github.com>1 parent d1079c8 commit f90df7b
1 file changed
Lines changed: 23 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
72 | 78 | | |
73 | 79 | | |
74 | 80 | | |
| |||
514 | 520 | | |
515 | 521 | | |
516 | 522 | | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
517 | 531 | | |
518 | 532 | | |
519 | 533 | | |
520 | 534 | | |
521 | 535 | | |
522 | 536 | | |
523 | 537 | | |
524 | | - | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
525 | 546 | | |
526 | 547 | | |
527 | 548 | | |
| |||
0 commit comments