Skip to content

Reschedule media uploads when the Wi-Fi-only preference changes - #3946

Merged
shobhitagarwal1612 merged 4 commits into
masterfrom
issue-3945
Sep 18, 2026
Merged

shobhitagarwal1612 merged 4 commits into
masterfrom
issue-3945

Conversation

@shobhitagarwal1612

@shobhitagarwal1612 shobhitagarwal1612 commented Sep 16, 2026

Copy link
Copy Markdown
Member

Fixes #3945

WorkManager constraints are immutable once a request is enqueued, so unchecking "Upload photos over Wi-Fi only" never applied to media uploads which had already been scheduled. Appending a new request left it blocked behind work still awaiting an unmetered connection, so pending photos were only uploaded once the device rejoined Wi-Fi.

Replace pending media upload work when the preference changes so that the newly selected network type takes effect, and cancel it when local data is cleared, so that work left behind by a signed out user can't block uploads enqueued by the next one.

Also adds missing test coverage for the worker.

Screen_recording_20260916_222109.webm

@jo-spek @gino-m PTAL?

WorkManager constraints are immutable once a request is enqueued, so
unchecking "Upload photos over Wi-Fi only" never applied to media
uploads which had already been scheduled. Appending a new request left
it blocked behind work still awaiting an unmetered connection, so
pending photos were only uploaded once the device rejoined Wi-Fi.

Replace pending media upload work when the preference changes so that
the newly selected network type takes effect, and cancel it when local
data is cleared, so that work left behind by a signed out user can't
block uploads enqueued by the next one.

Fixes #3945
@jo-spek

jo-spek commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

Awesome! Thanks for the hyper-quick fix :)

@codecov

codecov Bot commented Sep 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.14%. Comparing base (308ec92) to head (418b6d9).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3946      +/-   ##
============================================
+ Coverage     69.99%   70.14%   +0.15%     
- Complexity     2033     2046      +13     
============================================
  Files           424      424              
  Lines         11647    11654       +7     
  Branches       1522     1524       +2     
============================================
+ Hits           8152     8175      +23     
+ Misses         2723     2708      -15     
+ Partials        772      771       -1     
Files with missing lines Coverage Δ
...atform/android/data/sync/MediaUploadWorkManager.kt 100.00% <100.00%> (+84.61%) ⬆️
...roundplatform/android/repository/UserRepository.kt 84.84% <100.00%> (+1.79%) ⬆️

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gino-m

gino-m commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the ability to reschedule or cancel pending media uploads in response to changes in the user's network preferences or when user data is cleared (e.g., during sign-out). This is achieved by updating MediaUploadWorkManager and integrating it into UserRepository, along with adding corresponding unit tests. The review feedback suggests a valuable optimization to rescheduleSyncWorker() to check for existing pending work before rescheduling, which avoids unnecessary WorkManager overhead when the queue is empty, and recommends updating the test suite to reflect this change.

@jo-spek jo-spek left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good from my end

@shobhitagarwal1612
shobhitagarwal1612 merged commit 6bc8974 into master Sep 18, 2026
14 of 16 checks passed
@shobhitagarwal1612
shobhitagarwal1612 deleted the issue-3945 branch September 18, 2026 15:15

This branch is waiting to be deployed

1 waiting deployment
e2e-approval 418b6d96 Waiting Sep 18, 2026 by kenstershiro via instrumentation-tests / request-approval #1177
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Media upload pending despite switching off "WiFi-upload only"

4 participants