| @@ -353,6 +353,7 @@ func GetOneLevelAllObjectUnderDir(bucket string, prefixRootPath string, relative | |||||
| output, err := ObsCli.ListObjects(input) | output, err := ObsCli.ListObjects(input) | ||||
| fileInfos := make([]FileInfo, 0) | fileInfos := make([]FileInfo, 0) | ||||
| prefixLen := len(input.Prefix) | prefixLen := len(input.Prefix) | ||||
| fileMap := make(map[string]bool, 0) | |||||
| if err == nil { | if err == nil { | ||||
| for _, val := range output.Contents { | for _, val := range output.Contents { | ||||
| log.Info("val key=" + val.Key) | log.Info("val key=" + val.Key) | ||||
| @@ -362,16 +363,27 @@ func GetOneLevelAllObjectUnderDir(bucket string, prefixRootPath string, relative | |||||
| continue | continue | ||||
| } | } | ||||
| if strings.Contains(val.Key[prefixLen:len(val.Key)-1], "/") { | if strings.Contains(val.Key[prefixLen:len(val.Key)-1], "/") { | ||||
| continue | |||||
| } | |||||
| if strings.HasSuffix(val.Key, "/") { | |||||
| isDir = true | |||||
| fileName = val.Key[prefixLen : len(val.Key)-1] | fileName = val.Key[prefixLen : len(val.Key)-1] | ||||
| relativePath += val.Key[prefixLen:] | |||||
| files := strings.Split(fileName, "/") | |||||
| fileName = files[0] | |||||
| isDir = true | |||||
| if fileMap[files[0]] { | |||||
| continue | |||||
| } else { | |||||
| fileMap[files[0]] = true | |||||
| } | |||||
| } else { | } else { | ||||
| isDir = false | |||||
| fileName = val.Key[prefixLen:] | |||||
| if strings.HasSuffix(val.Key, "/") { | |||||
| isDir = true | |||||
| fileName = val.Key[prefixLen : len(val.Key)-1] | |||||
| relativePath += val.Key[prefixLen:] | |||||
| } else { | |||||
| isDir = false | |||||
| fileName = val.Key[prefixLen:] | |||||
| } | |||||
| fileMap[fileName] = true | |||||
| } | } | ||||
| fileInfo := FileInfo{ | fileInfo := FileInfo{ | ||||
| ModTime: val.LastModified.Local().Format("2006-01-02 15:04:05"), | ModTime: val.LastModified.Local().Format("2006-01-02 15:04:05"), | ||||
| FileName: fileName, | FileName: fileName, | ||||