From 81a2cd16e742427d80089ecd54bffcd9f4031a5b Mon Sep 17 00:00:00 2001 From: Benguang Zhao Date: Thu, 13 Jul 2023 17:37:53 +0800 Subject: [PATCH] enh: unify handling of vnode primary dir in current_fname --- source/dnode/vnode/src/tsdb/tsdbFS2.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/source/dnode/vnode/src/tsdb/tsdbFS2.c b/source/dnode/vnode/src/tsdb/tsdbFS2.c index 13a88d1011..ff38d4cc00 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFS2.c +++ b/source/dnode/vnode/src/tsdb/tsdbFS2.c @@ -15,6 +15,7 @@ #include "tsdbFS2.h" #include "tsdbUpgrade.h" +#include "vnd.h" extern int vnodeScheduleTask(int (*execute)(void *), void *arg); extern int vnodeScheduleTaskEx(int tpid, int (*execute)(void *), void *arg); @@ -69,23 +70,12 @@ static int32_t destroy_fs(STFileSystem **fs) { } int32_t current_fname(STsdb *pTsdb, char *fname, EFCurrentT ftype) { - if (pTsdb->pVnode->pTfs) { - snprintf(fname, // - TSDB_FILENAME_LEN, // - "%s%s%s%s%s", // - tfsGetPrimaryPath(pTsdb->pVnode->pTfs), // - TD_DIRSEP, // - pTsdb->path, // - TD_DIRSEP, // - gCurrentFname[ftype]); - } else { - snprintf(fname, // - TSDB_FILENAME_LEN, // - "%s%s%s", // - pTsdb->path, // - TD_DIRSEP, // - gCurrentFname[ftype]); - } + int32_t offset = 0; + + vnodeGetPrimaryDir(pTsdb->path, pTsdb->pVnode->pTfs, fname, TSDB_FILENAME_LEN); + offset = strlen(fname); + snprintf(fname + offset, TSDB_FILENAME_LEN - offset - 1, "%s%s", TD_DIRSEP, gCurrentFname[ftype]); + return 0; } @@ -892,4 +882,4 @@ int32_t tsdbFSEnableBgTask(STFileSystem *fs) { fs->stop = false; taosThreadMutexUnlock(fs->mutex); return 0; -} \ No newline at end of file +} -- GitLab