avoid listing empty dir
This commit is contained in:
parent
b6d61250cf
commit
5b8422b70d
|
@ -24,8 +24,9 @@ import (
|
|||
|
||||
// TreeWalkResult - Tree walk result carries results of tree walking.
|
||||
type TreeWalkResult struct {
|
||||
entry string
|
||||
end bool
|
||||
entry string
|
||||
emptyDir bool
|
||||
end bool
|
||||
}
|
||||
|
||||
// Return entries that have prefix prefixEntry.
|
||||
|
@ -254,7 +255,7 @@ func doTreeWalk(ctx context.Context, bucket, prefixDir, entryPrefixMatch, marker
|
|||
select {
|
||||
case <-endWalkCh:
|
||||
return false, errWalkAbort
|
||||
case resultCh <- TreeWalkResult{entry: pathJoin(prefixDir, entry), end: isEOF}:
|
||||
case resultCh <- TreeWalkResult{entry: pathJoin(prefixDir, entry), emptyDir: leafDir, end: isEOF}:
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -977,7 +977,7 @@ func (s *xlStorage) WalkVersions(ctx context.Context, volume, dirPath, marker st
|
|||
dirObjects := make(map[string]struct{})
|
||||
for walkResult := range walkResultCh {
|
||||
var fiv FileInfoVersions
|
||||
if HasSuffix(walkResult.entry, SlashSeparator) {
|
||||
if HasSuffix(walkResult.entry, SlashSeparator) && !walkResult.emptyDir {
|
||||
_, dirObj := dirObjects[walkResult.entry]
|
||||
if dirObj {
|
||||
continue
|
||||
|
@ -1081,7 +1081,7 @@ func (s *xlStorage) Walk(ctx context.Context, volume, dirPath, marker string, re
|
|||
dirObjects := make(map[string]struct{})
|
||||
for walkResult := range walkResultCh {
|
||||
var fi FileInfo
|
||||
if HasSuffix(walkResult.entry, SlashSeparator) {
|
||||
if HasSuffix(walkResult.entry, SlashSeparator) && !walkResult.emptyDir {
|
||||
_, dirObj := dirObjects[walkResult.entry]
|
||||
if dirObj {
|
||||
continue
|
||||
|
|
Loading…
Reference in a new issue