@@ -334,7 +334,7 @@ int extract_query_param(const char *query, const char *key, char *output, size_t
334334 return -3 ; // Key not found
335335}
336336
337- bool network_compute_endpoints (sqlite3_context * context , network_data * data , const char * connection_string ) {
337+ bool network_compute_endpoints (sqlite3_context * context , network_data * data , const char * conn_string ) {
338338 // compute endpoints
339339 bool result = false;
340340
@@ -348,12 +348,16 @@ bool network_compute_endpoints (sqlite3_context *context, network_data *data, co
348348 char * check_endpoint = NULL ;
349349 char * upload_endpoint = NULL ;
350350
351+ char * conn_string_https = NULL ;
352+
351353 CURLUcode rc = CURLUE_OUT_OF_MEMORY ;
352354 CURLU * url = curl_url ();
353355 if (!url ) goto finalize ;
354356
357+ conn_string_https = cloudsync_string_replace_prefix (conn_string , "sqlitecloud://" , "https://" );
358+
355359 // set URL: https://UUID.g5.sqlite.cloud:443/chinook.sqlite?apikey=hWDanFolRT9WDK0p54lufNrIyfgLZgtMw6tb6fbPmpo
356- rc = curl_url_set (url , CURLUPART_URL , connection_string , 0 );
360+ rc = curl_url_set (url , CURLUPART_URL , conn_string_https , 0 );
357361 if (rc != CURLE_OK ) goto finalize ;
358362
359363 // https (MANDATORY)
@@ -421,6 +425,7 @@ bool network_compute_endpoints (sqlite3_context *context, network_data *data, co
421425 if (database ) curl_free (database );
422426 if (query ) curl_free (query );
423427 if (url ) curl_url_cleanup (url );
428+ if (conn_string_https && conn_string_https != conn_string ) cloudsync_memory_free (conn_string_https );
424429
425430 return result ;
426431}
@@ -658,6 +663,15 @@ void cloudsync_network_check_changes (sqlite3_context *context, int argc, sqlite
658663 cloudsync_network_check_internal (context , argc , argv );
659664}
660665
666+ void cloudsync_network_reset_check_version (sqlite3_context * context , int argc , sqlite3_value * * argv ) {
667+ DEBUG_FUNCTION ("cloudsync_network_reset_check_version" );
668+
669+ sqlite3 * db = sqlite3_context_db_handle (context );
670+ char * buf = "0" ;
671+ dbutils_settings_set_key_value (db , context , CLOUDSYNC_KEY_CHECK_DBVERSION , buf );
672+ dbutils_settings_set_key_value (db , context , CLOUDSYNC_KEY_CHECK_SEQ , buf );
673+ }
674+
661675// MARK: -
662676
663677int cloudsync_network_register (sqlite3 * db , char * * pzErrMsg , void * ctx ) {
@@ -681,7 +695,7 @@ int cloudsync_network_register (sqlite3 *db, char **pzErrMsg, void *ctx) {
681695 rc = dbutils_register_function (db , "cloudsync_network_check_changes" , cloudsync_network_check_changes , 0 , pzErrMsg , ctx , NULL );
682696 if (rc != SQLITE_OK ) return rc ;
683697
684- rc = dbutils_register_function (db , "cloudsync_network_check_changes_sync " , cloudsync_network_check_changes_sync , 2 , pzErrMsg , ctx , NULL );
698+ rc = dbutils_register_function (db , "cloudsync_network_reset_check_version " , cloudsync_network_reset_check_version , 0 , pzErrMsg , ctx , NULL );
685699 if (rc != SQLITE_OK ) return rc ;
686700
687701 return rc ;
0 commit comments