From 5c466ce2a2685fe7c5ccad57e2ee88f41f5b6139 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Wed, 19 Aug 2020 18:05:36 +0800 Subject: [PATCH] not remove tsdb dir --- src/tsdb/src/tsdbMain.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/tsdb/src/tsdbMain.c b/src/tsdb/src/tsdbMain.c index bc979cca84..827e5c3c6d 100644 --- a/src/tsdb/src/tsdbMain.c +++ b/src/tsdb/src/tsdbMain.c @@ -71,7 +71,18 @@ static void tsdbStopStream(STsdbRepo *pRepo); // Function declaration int32_t tsdbCreateRepo(char *rootDir, STsdbCfg *pCfg) { - taosRemoveDir(rootDir); + DIR *dir = opendir(rootDir); + if (dir) { + tsdbDebug("repository %s already exists", rootDir); + closedir(dir); + return 0; + } else { + if (ENOENT != errno) { + tsdbError("failed to open directory %s since %s", rootDir, strerror(errno)); + terrno = TAOS_SYSTEM_ERROR(errno); + return -1; + } + } if (mkdir(rootDir, 0755) < 0) { tsdbError("vgId:%d failed to create rootDir %s since %s", pCfg->tsdbId, rootDir, strerror(errno)); -- GitLab