From 94c91085d61e36484a9c2f558b1f0889d52e2843 Mon Sep 17 00:00:00 2001 From: xiao-77 Date: Wed, 11 Dec 2024 16:40:23 +0800 Subject: [PATCH] Add file version in json file. --- include/common/tglobal.h | 3 +++ source/common/src/tglobal.c | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/common/tglobal.h b/include/common/tglobal.h index dbce6826a3..cb27e76b35 100644 --- a/include/common/tglobal.h +++ b/include/common/tglobal.h @@ -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; diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index d6add7f3d9..98e19b5195 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -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