Skip to content

Commit

Permalink
fix repair stat error
Browse files Browse the repository at this point in the history
  • Loading branch information
sjqzhang committed Sep 20, 2024
1 parent a906ad2 commit 7f2498c
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions server/http_repair.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,21 @@ func (c *Server) RepairStatByDate(date string) StatDateFileInfo {
keyPrefix = fmt.Sprintf(keyPrefix, date, CONST_FILE_Md5_FILE_NAME)
iter := server.logDB.NewIterator(util.BytesPrefix([]byte(keyPrefix)), nil)
defer iter.Release()
filePathSet := mapset.NewSet()
withDocker := DOCKER_DIR != ""
for iter.Next() {
if err = json.Unmarshal(iter.Value(), &fileInfo); err != nil {
continue
}
fileCount = fileCount + 1
fileSize = fileSize + fileInfo.Size
filePath := c.GetFilePathByInfo(&fileInfo, withDocker)
if _, err := os.Stat(filePath); err != nil { //TODO 在海量文件情况下存在性能问题
continue
}
if !filePathSet.Contains(filePath) {
fileCount = fileCount + 1
fileSize = fileSize + fileInfo.Size
filePathSet.Add(filePath)
}
}
c.statMap.Put(date+"_"+CONST_STAT_FILE_COUNT_KEY, fileCount)
c.statMap.Put(date+"_"+CONST_STAT_FILE_TOTAL_SIZE_KEY, fileSize)
Expand Down Expand Up @@ -322,4 +331,4 @@ func (c *Server) Repair(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(c.util.JsonEncodePretty(result)))
}

}
}

0 comments on commit 7f2498c

Please sign in to comment.