Repository navigation
Apply records fetched outside the sync engine - #560
Open
streamxapp wants to merge 1 commit into
Open
streamxapp wants to merge 1 commit into
streamxapp wants to merge 1 commit into
Conversation
Adds applyFetchedRecordZoneChanges so an app can read a zone itself when CKSyncEngine skips the server, and still keep the sync metadata consistent. Engines released by stop() are cancelled and can no longer overwrite saved state or the activity counts.
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.
Problem
CKSyncEngine.fetchChanges()does not always go to the server. When no push, scheduled sync or app activation has flagged changes, the engine logsno zone IDs needing to be fetched, not fetching changes/no need to fetch changes for scope alland returns without a request. On an Apple TV left on one screen (never re-activated) with pushes not arriving, records saved on another device sat on the server for many minutes while every manualSyncEngine.fetchChanges()was skipped. A directCKDatabase.recordZoneChanges(inZoneWith:since:)saw them immediately.Apps can read a zone's changes themselves, but there is no public way to hand those records to
SyncEngine, so they can't be applied without bypassing the sync metadata (writing rows directly queues them as local edits and re-uploads them).Change
SyncEngine.applyFetchedRecordZoneChanges(modifications:deletions:scope:): runs records fetched outside the engine through the existinghandleFetchedRecordZoneChangespath, against the private or shared engine. Records the engine later delivers again merge as no-ops.stop()are cancelled, and their latestateUpdateand will/did fetch/send events are ignored, so they can't overwrite the running engine's saved state or leaveisFetchingChangesstuck. Activity counts reset onstop().applyRecordsFetchedOutsideTheEngine.Happy to adjust the API shape or split the
stop()hardening into its own PR.🤖 Generated with Claude Code