fix(upload): schedule all background batches with unique Workmanager work names#2239
Draft
cursor[bot] wants to merge 1 commit into
Draft
fix(upload): schedule all background batches with unique Workmanager work names#2239cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes background multipart file uploads when
batchSizesplits 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
What Has Changed
upload_files_action.dart, replace mistakenreturnwithcontinueafter_setBackgroundUploadTaskso everyfileBatchis processed whenisBackgroundTaskis true.taskIdas the first argument toWorkmanager().registerOneOffTask(unique work name) instead of the fixed stringuploadTask, while keepingbackgroundUploadTaskas the callback task key andtag: taskIdfor cancellation by tag.How to Test
modules/ensemble, runflutter test(Flutter SDK on PATH perAGENTS.md).isBackgroundTask: true,batchSizesmaller 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
flutter analyzeand addressed any new warningsflutter testand all tests passNote: The CI image used for this automation did not have the Flutter SDK on
PATH, soflutter analyze/flutter testwere not executed here. Please run them locally perAGENTS.md.Duplicate check
UploadFilesResponse.cancelAll()(returnvscontinuein a different loop indata_context.dart); same concern class (mistakenreturn) but different code path and trigger (cancelling mixed completed/in-flight uploads vs batching background uploads).ensemble.storage.clear()async ordering; no overlap.batchSize+ background: originalbatchSizefeature (PR 985) did not adjust the background loop.