@@ -2331,6 +2331,9 @@ void cloudsync_payload_save (sqlite3_context *context, int argc, sqlite3_value *
23312331 snprintf (buf , sizeof (buf ), "%lld" , new_seq );
23322332 dbutils_settings_set_key_value (db , context , CLOUDSYNC_KEY_SEND_SEQ , buf );
23332333 }
2334+
2335+ // returns blob size
2336+ sqlite3_result_int64 (context , (sqlite3_int64 )blob_size );
23342337}
23352338
23362339void cloudsync_payload_load (sqlite3_context * context , int argc , sqlite3_value * * argv ) {
@@ -2344,7 +2347,6 @@ void cloudsync_payload_load (sqlite3_context *context, int argc, sqlite3_value *
23442347
23452348 // retrieve full path to file
23462349 const char * path = (const char * )sqlite3_value_text (argv [0 ]);
2347- file_delete (path );
23482350
23492351 size_t payload_size = 0 ;
23502352 char * payload = file_read (path , & payload_size );
@@ -2355,6 +2357,8 @@ void cloudsync_payload_load (sqlite3_context *context, int argc, sqlite3_value *
23552357
23562358 int nrows = cloudsync_payload_apply (context , payload , (int )payload_size );
23572359 if (payload ) cloudsync_memory_free (payload );
2360+
2361+ // returns number of applied rows
23582362 if (nrows != -1 ) sqlite3_result_int (context , nrows );
23592363}
23602364
@@ -3027,6 +3031,8 @@ void cloudsync_terminate (sqlite3_context *context, int argc, sqlite3_value **ar
30273031 // reset the site_id so the cloudsync_context_init will be executed again
30283032 // if any other cloudsync function is called after terminate
30293033 data -> site_id [0 ] = 0 ;
3034+
3035+ sqlite3_result_int (context , 1 );
30303036}
30313037
30323038// MARK: -
@@ -3187,8 +3193,18 @@ void cloudsync_init (sqlite3_context *context, const char *table, const char *al
31873193 }
31883194 }
31893195
3190- if (rc == SQLITE_OK ) dbutils_update_schema_hash (db , & data -> schema_hash );
3191- else sqlite3_exec (db , "ROLLBACK TO cloudsync_init; RELEASE cloudsync_init" , NULL , NULL , NULL );
3196+ // in case of error, rollback transaction
3197+ if (rc != SQLITE_OK ) {
3198+ sqlite3_exec (db , "ROLLBACK TO cloudsync_init; RELEASE cloudsync_init" , NULL , NULL , NULL );
3199+ return ;
3200+ }
3201+
3202+ dbutils_update_schema_hash (db , & data -> schema_hash );
3203+
3204+ // returns site_id as TEXT
3205+ char buffer [UUID_STR_MAXLEN ];
3206+ cloudsync_uuid_v7_stringify (data -> site_id , buffer , false);
3207+ sqlite3_result_text (context , buffer , -1 , NULL );
31923208}
31933209
31943210void cloudsync_init3 (sqlite3_context * context , int argc , sqlite3_value * * argv ) {
0 commit comments