Skip to content

fix(upload): schedule all background batches with unique Workmanager work names#2239

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-remediation-79b2
Draft

fix(upload): schedule all background batches with unique Workmanager work names#2239
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-remediation-79b2

Conversation

@cursor
Copy link
Copy Markdown

@cursor cursor Bot commented May 27, 2026

Description

Fixes background multipart file uploads when batchSize splits the file list into multiple batches. The batch loop returned after scheduling only the first chunk, so remaining files were never uploaded. Each batch is now scheduled in turn.

Also uses the generated per-task id as the Workmanager unique work name instead of the constant uploadTask. With the default existing-work policy, repeating the same unique name can cause later registrations to be ignored while an earlier job is still pending, which would drop batches even after fixing the loop.

Related Issue

None filed.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)

What Has Changed

  • In upload_files_action.dart, replace mistaken return with continue after _setBackgroundUploadTask so every fileBatch is processed when isBackgroundTask is true.
  • Pass taskId as the first argument to Workmanager().registerOneOffTask (unique work name) instead of the fixed string uploadTask, while keeping backgroundUploadTask as the callback task key and tag: taskId for cancellation by tag.

How to Test

  1. From modules/ensemble, run flutter test (Flutter SDK on PATH per AGENTS.md).
  2. Manual: configure a file upload with isBackgroundTask: true, batchSize smaller than the number of files, and confirm a Workmanager job is registered per batch (or that all files are eventually processed).

Screenshots / Videos

N/A

Checklist

  • I have run flutter analyze and addressed any new warnings
  • I have run flutter test and all tests pass
  • I have tested my changes on the relevant platform(s)
  • I have updated documentation if needed
  • My changes do not introduce new warnings or errors

Note: The CI image used for this automation did not have the Flutter SDK on PATH, so flutter analyze / flutter test were not executed here. Please run them locally per AGENTS.md.

Duplicate check

Open in Web View Automation 

…names

Background file uploads used `return` after the first batch when `batchSize`
split the selection, so later chunks were never enqueued. Use the per-task id
as the one-off unique name instead of a constant so Workmanager does not drop
subsequent registrations under the default existing-work policy.

Co-authored-by: Sharjeel Yunus <sharjeelyunus@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant