Skip to content

feat(autoupload): add manual scan action - #1

Closed
ohthehugemanatee wants to merge 2 commits into
masterfrom
claude/nextcloud-android-15782-othk5f
Closed

feat(autoupload): add manual scan action#1
ohthehugemanatee wants to merge 2 commits into
masterfrom
claude/nextcloud-android-15782-othk5f

Conversation

@ohthehugemanatee

@ohthehugemanatee ohthehugemanatee commented Aug 11, 2026

Copy link
Copy Markdown
Owner

Draft — notes for the contributor, not a finished description. Per the Nextcloud AI policy the PR description must be in your own words before this is submitted for review. Rewrite the sections below as you see fit.

Addresses nextcloud#15782 — "Auto upload - Button to manually scan files in the file system and re-upload missing files."

Auto upload is only woken by three things: ContentObserverWork (the OS content-URI trigger), app start when startAutoUploadOnStart() is set, and saving/toggling a folder configuration. There is no periodic scan job — JOB_PERIODIC_FILES_SYNC is declared in BackgroundJobManagerImpl but never scheduled. So when the content observer misses a file, nothing ever re-walks the folder and the file stays unuploaded indefinitely. The only user-facing workaround today is deleting an auto-upload configuration and recreating it with "also upload existing files".

AutoUploadWorker already performs a complete rescan on every run (AutoUploadHelper.insertEntries() walks MediaStore for image/video folders and Files.walkFileTree for custom folders). It just refuses to start unless something wakes it: canExitEarly() returns early on power saving or an unelapsed scan interval, both of which are bypassed by overridePowerSaving.

This adds a Manual scan item to the Auto upload screen's overflow menu that calls the existing FilesSyncHelper.startAutoUploadForEnabledSyncedFolders(..., overridePowerSaving = true) for every enabled synced folder — the same call ContentObserverWork makes, only forced. No new worker, no new job, no new scan logic; the feature itself is 20 lines across three files.

Deliberate scope limits, kept out to keep the diff minimal:

  • Files the local filesystem table already records as fileSentForUpload = 1 are not re-queued, so a file the DB believes uploaded but that is absent server-side is not recovered. That would need a force-rescan flag threaded through BackgroundJobManagerAutoUploadWorkerAutoUploadHelperFileSystemRepositorySyncedFolder.shouldSkipFile, plus a DAO reset.
  • Pre-existing files are still filtered when a folder has "also upload existing files" off — that is user configuration, not a bug.
  • startAutoUpload enqueues with ExistingWorkPolicy.KEEP, so if a sync for a folder is already queued the manual request coalesces into it.

🖼️ Screenshots

Not captured — the change was made in a headless environment with no Android SDK or emulator. The new entry is a standard overflow menu item in the Auto upload screen; the ⋮ button already existed, and the existing screenshot baselines capture the empty-list view and dialogs rather than an expanded menu, so no baseline should shift.

🏁 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?)

On tests: FilesSyncHelperTest covers startAutoUploadForEnabledSyncedFolders, which had no test coverage at all despite being the dispatch point for every auto-upload trigger in the app. It asserts that only isEnabled folders are started and that overridePowerSaving reaches the job manager — the behaviour the manual scan action depends on, since this is the first caller to pass true.

The menu wiring itself is not covered. No test in this codebase asserts that a menu item exists or is handled (across 84 instrumented test files there is no findItem, R.menu. or onCreateOptionsMenu usage), so a menu-presence test would be out of pattern and would mostly restate the XML. Happy to add one if reviewers disagree.

Nothing here has been executed. Gradle cannot run in the environment this branch was written in: the network policy blocks dl.google.com, the only host serving the Android Gradle Plugin (maven.google.com 301-redirects there), and there is no Android SDK installed. So lint, detekt, spotlessKotlinCheck, spotbugsGplayDebug and both test suites were skipped. Before submitting, please run:

./gradlew check
./gradlew jacocoTestGplayDebugUnitTest

🤖 AI (if applicable)

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

Generated with Claude Code; both commits carry an Assisted-by: trailer. Needs your review, your own PR description, and your Signed-off-by before submission.

@ohthehugemanatee
ohthehugemanatee force-pushed the claude/nextcloud-android-15782-othk5f branch from 6fb3244 to f4fe9dd Compare August 11, 2026 21:21
@ohthehugemanatee ohthehugemanatee changed the title feat(autoupload): add action to scan for missing files feat(autoupload): add manual scan action Aug 11, 2026
@ohthehugemanatee
ohthehugemanatee force-pushed the claude/nextcloud-android-15782-othk5f branch from 68c647d to fe9c987 Compare August 12, 2026 03:51
Auto upload is only woken by the OS content observer, app start and
folder configuration changes; there is no periodic scan job. When the
content observer misses a file, nothing ever re-walks the folder and the
file stays unuploaded.

Add a "Scan for missing files" item to the Auto upload screen overflow
menu that starts the auto upload worker for every enabled synced folder
with overridePowerSaving set, which bypasses the power-saving and scan
interval early exits so the folder is re-walked immediately.

Assisted-by: ClaudeCode:claude-opus-5
Signed-off-by: Campbell Vertesi <campbell@vertesi.com>
FilesSyncHelper.startAutoUploadForEnabledSyncedFolders had no coverage.
Assert that it starts auto upload only for enabled synced folders and
that overridePowerSaving reaches the job manager, which is what the new
manual scan action relies on.

Assisted-by: ClaudeCode:claude-opus-5
Signed-off-by: Campbell Vertesi <campbell@vertesi.com>
@ohthehugemanatee
ohthehugemanatee force-pushed the claude/nextcloud-android-15782-othk5f branch from fe9c987 to 317ab09 Compare August 12, 2026 04:14
@ohthehugemanatee

ohthehugemanatee commented Aug 12, 2026

Copy link
Copy Markdown
Owner Author

this PR on my fork is only for validation purposes. The real PR is #nextcloud/android/17462

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