fix(collections): prevent sync pull from wiping local collections#17
Draft
cursor[bot] wants to merge 1 commit into
Draft
fix(collections): prevent sync pull from wiping local collections#17cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
Commit 5a0b623 removed the guard that skipped applying an empty remote collections JSON when the device already had local collections. That let pullFromServer wipe unsynced local collections and debounced push could persist the empty state to the server. Restore the preservation check with JsonNull-aware empty detection and add unit tests for isRemoteCollectionsEmpty. Co-authored-by: Fab <CreepsoOff@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.
Summary
Restores a safety guard in
CollectionSyncService.pullFromServerthat was accidentally removed in commit5a0b6237. When the server returns an empty collections payload ([]ornull) but the device already has local collections, the app now preserves local data instead of applying the empty remote state.Bug and impact
Data loss: Users with locally created collections could lose them on the next sync pull if the server row was still empty (first sync, offline usage, or migration). The pull applied
[]over non-empty local state, and debounced push could then persist the wipe to the server.Root cause
5a0b6237refactoredJsonNullhandling and dropped this block:Fix
isRemoteCollectionsEmpty()(handlesJsonNull, emptyJsonArray, and legacy serialized forms).CollectionSyncServiceTestfor empty-remote detection.Validation
:composeApp:desktopTestnot run in CI agent environment (missingmediamp-mpvdependency on Linux host).