fix(sync): recover missing remote destinations#197
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves the remote destination picker’s resilience when a suggested Nextcloud sync destination doesn’t exist yet by surfacing typed WebDAV listing failures (HTTP status) across Android and desktop, and using that to recover to an accessible parent and offer explicit, confirmed folder creation.
Changes:
- Introduce
NextcloudFileListingHttpExceptionand throw it on non-success WebDAV folder listing responses (Android + desktop). - Add shared UI recovery logic to walk up ancestors on typed 404s and present an explicit “create and use” flow for missing suggested destinations.
- Preserve picker state across recreation via
rememberSaveable, and extend tests to cover the new recovery and typed-error behavior.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| ui/src/desktopTest/kotlin/dev/obiente/nextcloudnative/app/NextcloudFileListingFailureTest.kt | Adds a desktop test asserting typed HTTP status exposure. |
| ui/src/desktopMain/kotlin/dev/obiente/nextcloudnative/app/DesktopNextcloudServices.kt | Throws typed listing exception instead of generic error on non-207 responses. |
| ui/src/commonTest/kotlin/dev/obiente/nextcloudnative/app/RemoteFolderPickerTest.kt | Adds tests for missing-destination recovery, typed 404-only behavior, and UI status messaging. |
| ui/src/commonMain/kotlin/dev/obiente/nextcloudnative/app/RemoteFolderPicker.kt | Implements missing suggested destination recovery + confirmed nested creation; persists dialog state across recreation. |
| ui/src/commonMain/kotlin/dev/obiente/nextcloudnative/app/NextcloudFileListing.kt | Introduces typed HTTP exception for folder listing failures. |
| androidApp/src/test/kotlin/dev/obiente/nextcloudnative/NextcloudFileListingFailureTest.kt | Adds an Android unit test asserting typed HTTP status exposure. |
| androidApp/src/main/kotlin/dev/obiente/nextcloudnative/AndroidNextcloudServices.kt | Throws typed listing exception instead of generic error on non-207 responses. |
Comments suppressed due to low confidence (1)
ui/src/commonMain/kotlin/dev/obiente/nextcloudnative/app/RemoteFolderPicker.kt:271
missingDestinationis not reset when a new load starts, so a previously computed missing-destination banner/status can persist while showing cached results or after a network failure. This can mislead users (e.g., it can still say the destination will be created even though the current listing isn't network-confirmed and the confirm button is disabled). ClearmissingDestinationalongside the other per-load state resets so it's only shown after a successful network listing recomputes it.
LaunchedEffect(session, userId, currentPath, loadAttempt) {
files = null
listingSource = null
networkConfirmedPath = null
loading = true
refreshing = false
error = null
query = ""
val cached = runCatching {
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+301
to
+303
| val recoveryParent = recoveryTarget?.let { | ||
| missingRemoteFolderParentAfter(failure, currentPath) | ||
| } |
Comment on lines
+679
to
+692
| scope.launch { | ||
| runCatching { | ||
| destination.pathsToCreate.forEach { path -> | ||
| services.createDirectoryIfAbsent(session, userId, path) | ||
| } | ||
| }.rethrowRemoteFolderCancellation().onSuccess { | ||
| recoveryTarget = null | ||
| missingDestination = null | ||
| onSelected(destination.intendedPath) | ||
| }.onFailure { failure -> | ||
| createError = failure.message ?: "Could not create this destination." | ||
| } | ||
| createRunning = false | ||
| } |
Comment on lines
+667
to
+670
| enabled = canConfirm || ( | ||
| !createRunning && | ||
| missingDestination?.accessibleParentPath == networkConfirmedPath | ||
| ), |
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.
Summary
Validation
:ui:desktopTestfocused picker and desktop status tests:androidApp:testDebugUnitTestfocused Android status test:androidApp:assembleDebugCloses #192