feat(app): enqueue gallery batch concurrently via Future.wait

Parallelize the enqueueForUpload collect loop (preparer's internal
bounded semaphore from the previous task keeps IO in check). Also two
test hardenings from that task's code review: pin that failed and
thrown prepare operations release their concurrency slot (cap=1,
subsequent prepare still completes), and pin the maxConcurrentPrepares
<1 -> 1 clamp (peak 1, no deadlock).

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
浅念
2026-09-28 13:53:42 +08:00
parent b79edf447b
commit 93e7046332
2 changed files with 51 additions and 10 deletions
+11 -10
View File
@@ -149,16 +149,17 @@ Future<EnqueueResult> enqueueForUpload(
.where((path) => !skipSet.contains(path))
.toList();
var enqueued = 0;
for (final path in effective) {
final task = await preparer.prepare(
accountId: accountId,
albumId: albumId,
categoryId: categoryId,
sourcePath: path,
);
if (task.state == UploadTaskState.queued) enqueued++;
}
final results = await Future.wait(
effective.map((path) => preparer.prepare(
accountId: accountId,
albumId: albumId,
categoryId: categoryId,
sourcePath: path,
)),
);
final enqueued = results
.where((task) => task.state == UploadTaskState.queued)
.length;
return EnqueueResult(
enqueued: enqueued,