Skip to content

fix(auto-upload): restart folder runs that stay enqueued on rescan - #17805

Open
ToteMeiSter wants to merge 1 commit into
nextcloud:masterfrom
ToteMeiSter:fix/auto-upload-requeue-stuck-runs
Open

ToteMeiSter wants to merge 1 commit into
nextcloud:masterfrom
ToteMeiSter:fix/auto-upload-requeue-stuck-runs

Conversation

@ToteMeiSter

@ToteMeiSter ToteMeiSter commented Oct 12, 2026 •

Copy link
Copy Markdown

Refs #17439

Problem

Every synced folder has its own one-time AutoUploadWorker run (immediate_files_sync_<id>), enqueued with ExistingWorkPolicy.KEEP. isAutoUploadScheduled treats every unfinished run as active. When a run stays in ENQUEUED, every later request for that folder is dropped: the content observer, app start and AutoUploadRescanWorker. AutoUploadRescanWorker calls cancelEnqueuedAutoUploads() to get a clean start, but that function only cancels runs with periodicityInfo != null. Per-folder runs are one-time work, so nothing is cancelled and the folder stays stuck.

Change

cancelEnqueuedAutoUploads() cancels every enqueued AutoUploadWorker run. Runs tagged _ignore_power_saving ("sync now") stay, because restarting them would drop the override. The rescan then enqueues the folders again through startAutoUploadForEnabledSyncedFoldersIfNotActive.

Notes

How to test

  • Unit: BackgroundJobManagerImplTest (3 tests: an enqueued folder run is cancelled; running and finished runs are kept; an enqueued "sync now" run is kept). The first test fails without the change (WantedButNotInvoked).
  • Device: Checked on a HUAWEI Mate X7 (DEL-LX9, EMUI 15.0.0, Android 12) with a test build: works, auto upload from several folders runs.

🏁 Checklist

  • ⛑️ Tests (unit and/or integration) are included or not needed
  • 🔙 Backport requests are created or not needed: /backport to stable-xx.x
  • 📅 Milestone is set
  • 🌸 PR title is meaningful (if it should be in the changelog: is it meaningful to users?)

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

The change was drafted with Claude Code (Assisted-by: Claude-Code:claude-opus-5-5).

The periodic rescan only cancelled enqueued runs that were periodic, but
per-folder runs are one-time work. A run stuck in ENQUEUED stayed
"scheduled", so ExistingWorkPolicy.KEEP swallowed every later request for
that folder from the content observer, app start and the rescan itself.
Cancel every enqueued run except explicit "sync now" runs so the rescan
enqueues them again.

Signed-off-by: Krainov Gleb <krajnov.g@kontentplus.ru>
Assisted-by: Claude-Code:claude-opus-5-5
@codecov

codecov Bot commented Oct 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
.../nextcloud/client/jobs/BackgroundJobManagerImpl.kt 0.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

This branch has not been deployed

No deployments
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.

1 participant