fix: not return prefix object when list bucket object in non-recursive

mode
This commit is contained in:
Qiu Jian
2019-08-07 18:57:23 +08:00
parent 804e7a122f
commit 4e82063782
2 changed files with 9 additions and 3 deletions
+6 -3
View File
@@ -200,9 +200,12 @@ func GetIObjects(bucket ICloudBucket, objectPrefix string, isRecursive bool) ([]
}
// Send all objects
if len(result.Objects) > 0 {
ret = append(ret, result.Objects...)
marker = result.Objects[len(result.Objects)-1].GetKey()
for i := range result.Objects {
if !isRecursive && result.Objects[i].GetKey() == objectPrefix {
continue
}
ret = append(ret, result.Objects[i])
marker = result.Objects[i].GetKey()
}
// Send all common prefixes if any.
+3
View File
@@ -130,6 +130,9 @@ func (bucket *SBucket) GetIObjects(prefix string, isRecursive bool) ([]cloudprov
if object.Err != nil {
return nil, errors.Wrap(object.Err, "ListObjects")
}
if !isRecursive && prefix == object.Key {
continue
}
obj := &SObject{
bucket: bucket,
SBaseCloudObject: cloudprovider.SBaseCloudObject{