Add file version in json file.

This commit is contained in:
xiao-77 2024-12-11 16:40:23 +08:00
parent c50781d089
commit 94c91085d6
2 changed files with 5 additions and 1 deletions

View File

@ -31,6 +31,9 @@ extern "C" {
#define SLOW_LOG_TYPE_OTHERS 0x4
#define SLOW_LOG_TYPE_ALL 0x7
#define GLOBAL_CONFIG_FILE_VERSION 1
#define LOCAL_CONFIG_FILE_VERSION 1
typedef enum {
DND_CA_SM4 = 1,
} EEncryptAlgor;

View File

@ -2768,6 +2768,7 @@ int32_t globalConfigSerialize(int32_t version, SArray *array, char **serialized)
char buf[30];
cJSON *json = cJSON_CreateObject();
if (json == NULL) goto _exit;
if (cJSON_AddNumberToObject(json, "file_version", GLOBAL_CONFIG_FILE_VERSION) == NULL) goto _exit;
if (cJSON_AddNumberToObject(json, "version", version) == NULL) goto _exit;
int sz = taosArrayGetSize(array);
@ -2828,7 +2829,7 @@ int32_t localConfigSerialize(SArray *array, char **serialized) {
cJSON *cField = cJSON_CreateObject();
if (cField == NULL) goto _exit;
if (cJSON_AddNumberToObject(json, "file_version", LOCAL_CONFIG_FILE_VERSION) == NULL) goto _exit;
if (!cJSON_AddItemToObject(json, "configs", cField)) goto _exit;
// cjson only support int32_t or double