Skip to content

Commit

Permalink
Merge branch 'master' into object-store
Browse files Browse the repository at this point in the history
Signed-off-by: Mofei Zhang <[email protected]>
  • Loading branch information
mervinkid committed Mar 19, 2020
2 parents 659ef34 + 9d75c1f commit 3216d99
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
43 changes: 23 additions & 20 deletions objectnode/fs_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -1188,32 +1188,35 @@ func (v *Volume) listDir(fileInfos []*FSFileInfo, prefixMap PrefixMap, parentId,
}

for _, child := range children {
log.LogDebugf("listDir: process child, inode(%v) name(%v) parentId(%v) isDir(%v) isRegular(%v)",
child.Inode, child.Name, parentId, os.FileMode(child.Type).IsDir(), os.FileMode(child.Type).IsRegular())

var path = strings.Join(append(dirs, child.Name), "/")

if os.FileMode(child.Type).IsDir() {
path += "/"
}
log.LogDebugf("listDir: process child, path(%v) prefix(%v) marker(%v) delimiter(%v)",
path, prefix, marker, delimiter)

if prefix != "" && !strings.HasPrefix(path, prefix) {
continue
}
if marker != "" && path < marker {
continue
}
if delimiter != "" {
var nonPrefixPart = strings.Replace(path, prefix, "", 1)
if idx := strings.Index(nonPrefixPart, delimiter); idx >= 0 {
var commonPrefix = prefix + util.SubString(nonPrefixPart, 0, idx)
prefixMap.AddPrefix(commonPrefix)
continue
}
}
if os.FileMode(child.Type).IsDir() {
fileInfos, prefixMap, err = v.listDir(fileInfos, prefixMap, child.Inode, maxKeys, append(dirs, child.Name), prefix, marker, delimiter)
if err != nil {
return fileInfos, prefixMap, err
}
} else {
path := strings.Join(dirs, "/")
if len(dirs) == 0 {
path += child.Name
} else {
path += "/" + child.Name
}
if marker != "" && path < marker {
continue
}
if prefix != "" && !strings.HasPrefix(path, prefix) {
continue
}
if delimiter != "" && strings.Contains(child.Name, delimiter) {
idx := strings.Index(path, delimiter)
prefix := util.SubString(path, 0, idx)
prefixMap.AddPrefix(prefix)
continue
}
fileInfo := &FSFileInfo{
Inode: child.Inode,
Path: path,
Expand Down
2 changes: 1 addition & 1 deletion objectnode/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ type Content struct {
}

type ListBucketResult struct {
XMLName xml.Name `xml:"ListBucketResults"`
XMLName xml.Name `xml:"ListBucketResult"`
Bucket string `xml:"Name"`
Prefix string `xml:"Prefix"`
Marker string `xml:"Marker"`
Expand Down

0 comments on commit 3216d99

Please sign in to comment.