mirror of https://github.com/minio/minio.git
Merge pull request #215 from harshavardhana/pr_out_sort_list_of_objects
This commit is contained in:
commit
e7992320c1
|
@ -17,6 +17,8 @@
|
||||||
package minioapi
|
package minioapi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"sort"
|
||||||
|
|
||||||
mstorage "github.com/minio-io/minio/pkg/storage"
|
mstorage "github.com/minio-io/minio/pkg/storage"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -52,6 +54,12 @@ func generateBucketsListResult(buckets []mstorage.BucketMetadata) BucketListResp
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ItemKey []*Item
|
||||||
|
|
||||||
|
func (b ItemKey) Len() int { return len(b) }
|
||||||
|
func (b ItemKey) Swap(i, j int) { b[i], b[j] = b[j], b[i] }
|
||||||
|
func (b ItemKey) Less(i, j int) bool { return b[i].Key < b[j].Key }
|
||||||
|
|
||||||
// takes a set of objects and prepares the objects for serialization
|
// takes a set of objects and prepares the objects for serialization
|
||||||
// input:
|
// input:
|
||||||
// bucket name
|
// bucket name
|
||||||
|
@ -78,6 +86,7 @@ func generateObjectsListResult(bucket string, objects []mstorage.ObjectMetadata,
|
||||||
content.Owner = owner
|
content.Owner = owner
|
||||||
contents = append(contents, content)
|
contents = append(contents, content)
|
||||||
}
|
}
|
||||||
|
sort.Sort(ItemKey(contents))
|
||||||
data.Name = bucket
|
data.Name = bucket
|
||||||
data.Contents = contents
|
data.Contents = contents
|
||||||
data.MaxKeys = MAX_OBJECT_LIST
|
data.MaxKeys = MAX_OBJECT_LIST
|
||||||
|
|
Loading…
Reference in New Issue