mirror of https://github.com/minio/minio.git
Add Marker support for donut, also add a testing code
This commit is contained in:
parent
142f9263e1
commit
6d3d92694f
|
@ -134,9 +134,22 @@ func (d donut) ListObjects(bucket, prefix, marker, delimiter string, maxkeys int
|
||||||
actualObjects = donutObjects
|
actualObjects = donutObjects
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sort.Strings(actualObjects)
|
||||||
|
var newActualObjects []string
|
||||||
|
switch {
|
||||||
|
case marker != "":
|
||||||
|
for _, objectName := range actualObjects {
|
||||||
|
if objectName > marker {
|
||||||
|
newActualObjects = append(newActualObjects, objectName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
newActualObjects = actualObjects
|
||||||
|
}
|
||||||
|
|
||||||
var results []string
|
var results []string
|
||||||
var commonPrefixes []string
|
var commonPrefixes []string
|
||||||
for _, objectName := range actualObjects {
|
for _, objectName := range newActualObjects {
|
||||||
if len(results) >= maxkeys {
|
if len(results) >= maxkeys {
|
||||||
isTruncated = true
|
isTruncated = true
|
||||||
break
|
break
|
||||||
|
|
|
@ -181,10 +181,25 @@ func testPaging(c *check.C, create func() Driver) {
|
||||||
c.Assert(resources.CommonPrefixes[0], check.Equals, "this/")
|
c.Assert(resources.CommonPrefixes[0], check.Equals, "this/")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check results with Marker
|
||||||
|
{
|
||||||
|
var prefixes []string
|
||||||
|
resources.CommonPrefixes = prefixes // allocate new everytime
|
||||||
|
resources.Prefix = ""
|
||||||
|
resources.Marker = "newPrefix"
|
||||||
|
resources.Delimiter = "/"
|
||||||
|
resources.Maxkeys = 3
|
||||||
|
objects, resources, err = drivers.ListObjects("bucket", resources)
|
||||||
|
c.Assert(objects[0].Key, check.Equals, "newPrefix2")
|
||||||
|
c.Assert(objects[1].Key, check.Equals, "obj0")
|
||||||
|
c.Assert(objects[2].Key, check.Equals, "obj1")
|
||||||
|
c.Assert(resources.CommonPrefixes[0], check.Equals, "this/")
|
||||||
|
}
|
||||||
// check ordering of results with prefix
|
// check ordering of results with prefix
|
||||||
{
|
{
|
||||||
resources.Prefix = "obj"
|
resources.Prefix = "obj"
|
||||||
resources.Delimiter = ""
|
resources.Delimiter = ""
|
||||||
|
resources.Marker = ""
|
||||||
resources.Maxkeys = 1000
|
resources.Maxkeys = 1000
|
||||||
objects, resources, err = drivers.ListObjects("bucket", resources)
|
objects, resources, err = drivers.ListObjects("bucket", resources)
|
||||||
c.Assert(objects[0].Key, check.Equals, "obj0")
|
c.Assert(objects[0].Key, check.Equals, "obj0")
|
||||||
|
@ -196,6 +211,7 @@ func testPaging(c *check.C, create func() Driver) {
|
||||||
// check ordering of results with prefix and no paging
|
// check ordering of results with prefix and no paging
|
||||||
{
|
{
|
||||||
resources.Prefix = "new"
|
resources.Prefix = "new"
|
||||||
|
resources.Marker = ""
|
||||||
resources.Maxkeys = 5
|
resources.Maxkeys = 5
|
||||||
objects, resources, err = drivers.ListObjects("bucket", resources)
|
objects, resources, err = drivers.ListObjects("bucket", resources)
|
||||||
c.Assert(objects[0].Key, check.Equals, "newPrefix")
|
c.Assert(objects[0].Key, check.Equals, "newPrefix")
|
||||||
|
|
Loading…
Reference in New Issue