fs: Do not return reservedBucket names in ListBuckets() (#3754)

Make sure to skip reserved bucket names in `ListBuckets()`
current code didn't skip this properly and also generalize
this behavior for both XL and FS.
This commit is contained in:
Harshavardhana
2017-02-16 14:52:14 -08:00
committed by GitHub
parent 8816b08aae
commit 50b4e54a75
28 changed files with 85 additions and 104 deletions

View File

@@ -129,7 +129,7 @@ func retainSlash(s string) string {
func pathJoin(elem ...string) string {
trailingSlash := ""
if len(elem) > 0 {
if strings.HasSuffix(elem[len(elem)-1], slashSeparator) {
if hasSuffix(elem[len(elem)-1], slashSeparator) {
trailingSlash = "/"
}
}
@@ -180,6 +180,15 @@ func hasSuffix(s string, suffix string) bool {
return strings.HasSuffix(s, suffix)
}
// Ignores all reserved bucket names or invalid bucket names.
func isReservedOrInvalidBucket(bucketEntry string) bool {
bucketEntry = strings.TrimSuffix(bucketEntry, slashSeparator)
if !IsValidBucketName(bucketEntry) {
return true
}
return bucketEntry == minioMetaBucket || bucketEntry == minioReservedBucket
}
// byBucketName is a collection satisfying sort.Interface.
type byBucketName []BucketInfo