Validate prefixes on all sets (#6294)

This PR fixes a regression introduced in 8eb838bf91
where hashing technique was used on prefixes to get the right set
to perform the operation, this is not correct since prefixes and
their corresponding keys might hash to a different value depending
on the key length.

For prefixes/directories we should look everywhere to support proper
quorum based listing.

Fixes #6293
This commit is contained in:
Harshavardhana 2018-08-16 16:49:38 -07:00 committed by kannappanr
parent c7946ab9ab
commit 0fe9e95250
1 changed files with 24 additions and 3 deletions

View File

@ -714,7 +714,15 @@ func (s *xlSets) ListObjects(ctx context.Context, bucket, prefix, marker, delimi
}
isLeafDir := func(bucket, entry string) bool {
return s.getHashedSet(entry).isObjectDir(bucket, entry)
// Verify prefixes in all sets.
var ok bool
for _, set := range s.sets {
ok = set.isObjectDir(bucket, entry)
if ok {
return true
}
}
return false
}
var setDisks = make([][]StorageAPI, len(s.sets))
@ -742,7 +750,13 @@ func (s *xlSets) ListObjects(ctx context.Context, bucket, prefix, marker, delimi
var objInfo ObjectInfo
var err error
if hasSuffix(walkResult.entry, slashSeparator) {
objInfo, err = s.getHashedSet(walkResult.entry).getObjectInfoDir(ctx, bucket, walkResult.entry)
// Verify prefixes in all sets.
for _, set := range s.sets {
objInfo, err = set.getObjectInfoDir(ctx, bucket, walkResult.entry)
if err == nil {
break
}
}
} else {
objInfo, err = s.getHashedSet(walkResult.entry).getObjectInfo(ctx, bucket, walkResult.entry)
}
@ -1349,7 +1363,14 @@ func (s *xlSets) listObjectsHeal(ctx context.Context, bucket, prefix, marker, de
}
isLeafDir := func(bucket, entry string) bool {
return s.getHashedSet(entry).isObjectDir(bucket, entry)
var ok bool
for _, set := range s.sets {
ok = set.isObjectDir(bucket, entry)
if ok {
return true
}
}
return false
}
var setDisks = make([][]StorageAPI, len(s.sets))