Skip to content

Commit 1f78c53

Browse files
committed
fix cloudsync_payload_apply from main branch
1 parent 58db5d0 commit 1f78c53

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/cloudsync.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2031,14 +2031,17 @@ int cloudsync_payload_apply (sqlite3_context *context, const char *payload, int
20312031
stmt_reset(vm);
20322032
}
20332033

2034-
char buf[256];
2035-
if (xdata.dbversion != dbversion) {
2036-
snprintf(buf, sizeof(buf), "%lld", xdata.dbversion);
2037-
dbutils_settings_set_key_value(db, context, CLOUDSYNC_KEY_CHECK_DBVERSION, buf);
2038-
}
2039-
if (xdata.seq != seq) {
2040-
snprintf(buf, sizeof(buf), "%lld", xdata.seq);
2041-
dbutils_settings_set_key_value(db, context, CLOUDSYNC_KEY_CHECK_SEQ, buf);
2034+
if (rc == SQLITE_DONE) rc = SQLITE_OK;
2035+
if (rc == SQLITE_OK) {
2036+
char buf[256];
2037+
if (xdata.dbversion != dbversion) {
2038+
snprintf(buf, sizeof(buf), "%lld", xdata.dbversion);
2039+
dbutils_settings_set_key_value(db, context, CLOUDSYNC_KEY_CHECK_DBVERSION, buf);
2040+
}
2041+
if (xdata.seq != seq) {
2042+
snprintf(buf, sizeof(buf), "%lld", xdata.seq);
2043+
dbutils_settings_set_key_value(db, context, CLOUDSYNC_KEY_CHECK_SEQ, buf);
2044+
}
20422045
}
20432046

20442047
// cleanup vm
@@ -2047,7 +2050,8 @@ int cloudsync_payload_apply (sqlite3_context *context, const char *payload, int
20472050
// cleanup memory
20482051
if (clone) cloudsync_memory_free(clone);
20492052

2050-
if (rc != SQLITE_DONE) {
2053+
if (rc != SQLITE_OK) {
2054+
sqlite3_result_error(context, sqlite3_errmsg(db), -1);
20512055
sqlite3_result_error_code(context, SQLITE_MISUSE);
20522056
return -1;
20532057
}

0 commit comments

Comments
 (0)