Merge pull request #3208 from taosdata/fmaster/lihui

Fmaster/lihui
This commit is contained in:
Shengliang Guan 2020-08-24 19:49:08 +08:00 committed by GitHub
commit 374c05602c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 11 deletions

View File

@ -23,7 +23,7 @@ extern "C" {
// TAOS_OS_FUNC_DIR
void taosRemoveDir(char *rootDir);
int taosMkDir(const char *pathname, mode_t mode);
void taosMvDir(char* destDir, char *srcDir);
void taosRename(char* oldName, char *newName);
#ifdef __cplusplus
}

View File

@ -50,18 +50,19 @@ int taosMkDir(const char *path, mode_t mode) {
return code;
}
void taosMvDir(char* destDir, char *srcDir) {
void taosRename(char* oldName, char *newName) {
if (0 == tsEnableVnodeBak) {
uInfo("vnode backup not enabled");
return;
}
char shellCmd[1024+1] = {0};
//(void)snprintf(shellCmd, 1024, "cp -rf %s %s", srcDir, destDir);
(void)snprintf(shellCmd, 1024, "mv %s %s", srcDir, destDir);
taosSystem(shellCmd);
uInfo("shell cmd:%s is executed", shellCmd);
// if newName in not empty, rename return fail.
// the newName must be empty or does not exist
if (rename(oldName, newName)) {
uError("%s is modify to %s fail, reason:%s", oldName, newName, strerror(errno));
} else {
uInfo("%s is modify to %s success!", oldName, newName);
}
}
#endif
#endif

View File

@ -358,9 +358,11 @@ void vnodeRelease(void *pVnodeRaw) {
taosTFree(pVnode->rootDir);
if (pVnode->dropped) {
char rootDir[TSDB_FILENAME_LEN] = {0};
char rootDir[TSDB_FILENAME_LEN] = {0};
char newDir[TSDB_FILENAME_LEN] = {0};
sprintf(rootDir, "%s/vnode%d", tsVnodeDir, vgId);
taosMvDir(tsVnodeBakDir, rootDir);
sprintf(newDir, "%s/vnode%d", tsVnodeBakDir, vgId);
taosRename(rootDir, newDir);
taosRemoveDir(rootDir);
dnodeSendStatusMsgToMnode();
}