diff --git a/modules/filecheck/collect.go b/modules/filecheck/collect.go index f2e1aae17..921846a75 100644 --- a/modules/filecheck/collect.go +++ b/modules/filecheck/collect.go @@ -3,6 +3,7 @@ package filecheck import ( + "regexp" "runtime" "strings" ) @@ -35,3 +36,5 @@ func removeDuplicates(s []string) []string { } return uniq } + +var reSpace = regexp.MustCompile(`\s`) diff --git a/modules/filecheck/collect_dirs.go b/modules/filecheck/collect_dirs.go index 2c4519d2b..32861c0e0 100644 --- a/modules/filecheck/collect_dirs.go +++ b/modules/filecheck/collect_dirs.go @@ -115,7 +115,7 @@ func (fc *Filecheck) addDirToCharts(path string) { continue } - dim := &module.Dim{ID: id, Name: path} + dim := &module.Dim{ID: id, Name: reSpace.ReplaceAllString(path, "_")} if err := chart.AddDim(dim); err != nil { fc.Warning(err) @@ -155,7 +155,7 @@ func (fc *Filecheck) removeDirFromCharts(path string) { } func dirDimID(path, metric string) string { - return fmt.Sprintf("dir_%s_%s", path, metric) + return fmt.Sprintf("dir_%s_%s", reSpace.ReplaceAllString(path, "_"), metric) } func calcDirNumOfFiles(dirpath string) (int, error) { diff --git a/modules/filecheck/collect_files.go b/modules/filecheck/collect_files.go index e154305b1..25568473f 100644 --- a/modules/filecheck/collect_files.go +++ b/modules/filecheck/collect_files.go @@ -106,7 +106,7 @@ func (fc *Filecheck) addFileToCharts(path string) { continue } - dim := &module.Dim{ID: id, Name: path} + dim := &module.Dim{ID: id, Name: reSpace.ReplaceAllString(path, "_")} if err := chart.AddDim(dim); err != nil { fc.Warning(err) @@ -144,5 +144,5 @@ func (fc *Filecheck) removeFileFromCharts(path string) { } func fileDimID(path, metric string) string { - return fmt.Sprintf("file_%s_%s", path, metric) + return fmt.Sprintf("file_%s_%s", reSpace.ReplaceAllString(path, "_"), metric) }