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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user