From 10a607154d71efb22c950abd3dc4ed02fea2ddcc Mon Sep 17 00:00:00 2001 From: poornas Date: Mon, 8 Apr 2019 15:12:00 -0700 Subject: [PATCH] Fix ListObjectsV2 for gateway encryption mode (#7491) Fixes #7468 by setting NextContinuationToken only if list is truncated --- cmd/gateway/s3/gateway-s3-sse.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cmd/gateway/s3/gateway-s3-sse.go b/cmd/gateway/s3/gateway-s3-sse.go index 0d64701f1..7fbd0c4e6 100644 --- a/cmd/gateway/s3/gateway-s3-sse.go +++ b/cmd/gateway/s3/gateway-s3-sse.go @@ -138,16 +138,19 @@ func (l *s3EncObjects) ListObjectsV2(ctx context.Context, bucket, prefix, contin loi.ContinuationToken = continuationToken loi.Objects = make([]minio.ObjectInfo, 0) loi.Prefixes = make([]string, 0) + loi.Objects = append(loi.Objects, objects...) - for _, obj := range objects { - loi.NextContinuationToken = obj.Name - loi.Objects = append(loi.Objects, obj) - } for _, pfx := range prefixes { if pfx != prefix { loi.Prefixes = append(loi.Prefixes, pfx) } } + // Set continuation token if s3 returned truncated list + if isTruncated { + if len(objects) > 0 { + loi.NextContinuationToken = objects[len(objects)-1].Name + } + } return loi, nil }