Merged
Conversation
- automatically update the latest sent db_version value after sending payloads depending on the status returned by the cloudsync http service - the cloudsync_network_send_changes functions now returns the status data in the json format - the cloudsync_network_has_unsent_changes now call the status endpoints before comparing with the latest local db_version - only consider the db_version value in the WHERE clause of cloudsync_payload_get, don't filter at seq level
The three public sync functions was leaking internal server JSON or returning raw integers. We want them to return coherent, user-facing JSON with a computed status field and relevant version/row info.
New responses:
- cloudsync_network_send_changes — formats JSON: {"status":"...", "localVersion":N, "serverVersion":N}
- cloudsync_network_check_changes — formats JSON: {"rowsReceived":N}
- cloudsync_network_sync — combines send + check results into: {"status":"...", "localVersion":N, "serverVersion":N, "rowsReceived":N}
The status helper computes "synced", "syncing", "retry", or "error" from the apply/status response fields.
…teCloud projects using RLS rules
…nd/receive keys
Change the flat JSON return format of network functions to a nested
structure with "send" and "receive" top-level keys, rename
"rowsReceived" to "rows" for conciseness, and add a "tables" array
field to the receive section listing affected table names.
Before: {"status":"synced","localVersion":5,"serverVersion":5,"rowsReceived":3}
After: {"send":{"status":"synced","localVersion":5,"serverVersion":5},"receive":{"rows":3,"tables":["tasks"]}}
Update integration tests to use SQLite's ->> operator for JSON field
extraction, and add db_expect_str helper for string assertions.
…ayload AND db_version == 0.
1. Added early return for empty-db case (lines 959–966): When there's no payload (blob == NULL || blob_size == 0) AND db_version == 0, skip the network call entirely and return { server_version: 0, local_version: 0, status: "synced" }. This avoids the 404 from the status endpoint when the server doesn't know the device yet.
2. Fixed condition from || to && (line 969): Changed blob != NULL || blob_size > 0 to blob != NULL && blob_size > 0 — both conditions must be true to confirm there's actual data to upload.
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.
Uh oh!
There was an error while loading. Please reload this page.