Skip to content

Commit a6333a6

Browse files
committed
fix: report error messages for errors in cloudsync_payload_apply
1 parent cc35c4c commit a6333a6

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/cloudsync.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2021,14 +2021,17 @@ int cloudsync_payload_apply (sqlite3_context *context, const char *payload, int
20212021
stmt_reset(vm);
20222022
}
20232023

2024-
char buf[256];
2025-
if (xdata.dbversion != dbversion) {
2026-
snprintf(buf, sizeof(buf), "%lld", xdata.dbversion);
2027-
dbutils_settings_set_key_value(db, context, CLOUDSYNC_KEY_CHECK_DBVERSION, buf);
2028-
}
2029-
if (xdata.seq != seq) {
2030-
snprintf(buf, sizeof(buf), "%lld", xdata.seq);
2031-
dbutils_settings_set_key_value(db, context, CLOUDSYNC_KEY_CHECK_SEQ, buf);
2024+
if (rc == SQLITE_DONE) rc = SQLITE_OK;
2025+
if (rc == SQLITE_OK) {
2026+
char buf[256];
2027+
if (xdata.dbversion != dbversion) {
2028+
snprintf(buf, sizeof(buf), "%lld", xdata.dbversion);
2029+
dbutils_settings_set_key_value(db, context, CLOUDSYNC_KEY_CHECK_DBVERSION, buf);
2030+
}
2031+
if (xdata.seq != seq) {
2032+
snprintf(buf, sizeof(buf), "%lld", xdata.seq);
2033+
dbutils_settings_set_key_value(db, context, CLOUDSYNC_KEY_CHECK_SEQ, buf);
2034+
}
20322035
}
20332036

20342037
// cleanup vm
@@ -2038,6 +2041,7 @@ int cloudsync_payload_apply (sqlite3_context *context, const char *payload, int
20382041
if (clone) cloudsync_memory_free(clone);
20392042

20402043
if (rc != SQLITE_DONE) {
2044+
sqlite3_result_error(context, sqlite3_errmsg(db), -1);
20412045
sqlite3_result_error_code(context, SQLITE_MISUSE);
20422046
return -1;
20432047
}

0 commit comments

Comments
 (0)