fix: remove code size checking

This commit is contained in:
slzhou 2023-04-08 13:26:15 +08:00
parent 55ffb0bc6d
commit dc86bf9671
1 changed files with 6 additions and 15 deletions

View File

@ -338,7 +338,7 @@ static void udfdConnectMnodeThreadFunc(void *args);
SUdf *udfdNewUdf(const char *udfName); SUdf *udfdNewUdf(const char *udfName);
void udfdGetFuncBodyPath(const SUdf *udf, char *path); void udfdGetFuncBodyPath(const SUdf *udf, char *path);
void udfdInitializeCPlugin(SUdfScriptPlugin *plugin) { void udfdInitializeCPlugin(SUdfScriptPlugin *plugin) {
plugin->scriptType = TSDB_FUNC_SCRIPT_BIN_LIB; plugin->scriptType = TSDB_FUNC_SCRIPT_BIN_LIB;
plugin->openFunc = udfdCPluginOpen; plugin->openFunc = udfdCPluginOpen;
plugin->closeFunc = udfdCPluginClose; plugin->closeFunc = udfdCPluginClose;
@ -811,14 +811,12 @@ void udfdProcessTeardownRequest(SUvUdfWork *uvUdf, SUdfRequest *request) {
return; return;
} }
void udfdGetFuncBodyPath(const SUdf *udf, char *path) { void udfdGetFuncBodyPath(const SUdf *udf, char *path) {
if (udf->scriptType == TSDB_FUNC_SCRIPT_BIN_LIB) { if (udf->scriptType == TSDB_FUNC_SCRIPT_BIN_LIB) {
#ifdef WINDOWS #ifdef WINDOWS
snprintf(path, PATH_MAX, "%s%s_%d_%" PRIx64 ".dll", tsDataDir, udf->name, udf->version, udf->createdTime); snprintf(path, PATH_MAX, "%s%s_%d_%" PRIx64 ".dll", tsDataDir, udf->name, udf->version, udf->createdTime);
#else #else
snprintf(path, PATH_MAX, "%s/lib%s_%d_%" PRIx64 ".so", tsDataDir, udf->name, udf->version, snprintf(path, PATH_MAX, "%s/lib%s_%d_%" PRIx64 ".so", tsDataDir, udf->name, udf->version, udf->createdTime);
udf->createdTime);
#endif #endif
} else if (udf->scriptType == TSDB_FUNC_SCRIPT_PYTHON) { } else if (udf->scriptType == TSDB_FUNC_SCRIPT_PYTHON) {
#ifdef WINDOWS #ifdef WINDOWS
@ -846,15 +844,8 @@ int32_t udfdSaveFuncBodyToFile(SFuncInfo *pFuncInfo, SUdf *udf) {
udfdGetFuncBodyPath(udf, path); udfdGetFuncBodyPath(udf, path);
bool fileExist = !(taosStatFile(path, NULL, NULL) < 0); bool fileExist = !(taosStatFile(path, NULL, NULL) < 0);
if (fileExist) { if (fileExist) {
// TODO: error processing strncpy(udf->path, path, PATH_MAX);
TdFilePtr file = taosOpenFile(path, TD_FILE_READ); return TSDB_CODE_SUCCESS;
int64_t size = 0;
taosFStatFile(file, &size, NULL);
taosCloseFile(&file);
if (size == pFuncInfo->codeSize) {
strncpy(udf->path, path, PATH_MAX);
return TSDB_CODE_SUCCESS;
}
} }
TdFilePtr file = taosOpenFile(path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_READ | TD_FILE_TRUNC); TdFilePtr file = taosOpenFile(path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_READ | TD_FILE_TRUNC);