fix tsdbGetFileInfo

This commit is contained in:
Hongze Cheng 2020-06-02 06:19:54 +00:00
parent dbdde975a6
commit 2e53d7a477
1 changed files with 18 additions and 39 deletions

View File

@ -1209,27 +1209,6 @@ uint32_t tsdbGetFileInfo(TsdbRepoT *repo, char *name, uint32_t *index, uint32_t
ASSERT(*index <= eindex); ASSERT(*index <= eindex);
if (name[0] == 0) { // get the file from index or after, but not larger than eindex if (name[0] == 0) { // get the file from index or after, but not larger than eindex
if (*index == 0) { // need to return the first file and set the *index
if (pFileH->numOfFGroups > 0) {
int fid = TSDB_MIN_FILE_ID(pFileH);
if (fid * 3 <= eindex) {
strcpy(fname, pFileH->fGroup[fid].files[0].fname);
*index = fid * 3;
strcpy(name, fname+strlen(pRepo->rootDir));
} else { // no file found
return 0;
}
} else {
if (TSDB_META_FILE_INDEX <= eindex) {
*index = TSDB_META_FILE_INDEX;
tsdbGetMetaFileName(pRepo->rootDir, fname);
strcpy(name, fname+strlen(pRepo->rootDir));
} else { // no file found
return 0;
}
}
} else { // return a file name at *index
if (*index == TSDB_META_FILE_INDEX) { if (*index == TSDB_META_FILE_INDEX) {
tsdbGetMetaFileName(pRepo->rootDir, fname); tsdbGetMetaFileName(pRepo->rootDir, fname);
} else { // to get a file in index or larger than index but } else { // to get a file in index or larger than index but
@ -1237,7 +1216,8 @@ uint32_t tsdbGetFileInfo(TsdbRepoT *repo, char *name, uint32_t *index, uint32_t
return 0; return 0;
} else { } else {
int fid = (*index) / 3; int fid = (*index) / 3;
SFileGroup *pFGroup = taosbsearch(&fid, pFileH->fGroup, pFileH->numOfFGroups, sizeof(SFileGroup), compFGroupKey, TD_GE); SFileGroup *pFGroup =
taosbsearch(&fid, pFileH->fGroup, pFileH->numOfFGroups, sizeof(SFileGroup), compFGroupKey, TD_GE);
if (pFGroup == NULL) { if (pFGroup == NULL) {
return 0; return 0;
} else { } else {
@ -1255,7 +1235,6 @@ uint32_t tsdbGetFileInfo(TsdbRepoT *repo, char *name, uint32_t *index, uint32_t
} }
} }
strcpy(name, fname); strcpy(name, fname);
}
} else { // get the named file at the specified index. If not there, return 0 } else { // get the named file at the specified index. If not there, return 0
if (*index == TSDB_META_FILE_INDEX) { // get meta file if (*index == TSDB_META_FILE_INDEX) { // get meta file
tsdbGetMetaFileName(pRepo->rootDir, fname); tsdbGetMetaFileName(pRepo->rootDir, fname);