From cdb458c9876a2b4a653f6c8e7a6448f0467b93cc Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Wed, 12 Aug 2020 16:03:30 -0700 Subject: [PATCH] fix: do not close contentCh prematurely without versioning --- cmd/client-s3.go | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/cmd/client-s3.go b/cmd/client-s3.go index 4990d140..e078619a 100644 --- a/cmd/client-s3.go +++ b/cmd/client-s3.go @@ -1653,13 +1653,11 @@ func (c *S3Client) List(ctx context.Context, opts ListOptions) <-chan *ClientCon return } for _, bucket := range buckets { - isVersion := true for objectVersion := range c.listVersions(ctx, bucket.Name, "", opts.isRecursive, opts.timeRef, opts.withOlderVersions, opts.withDeleteMarkers) { if objectVersion.Err != nil { if minio.ToErrorResponse(objectVersion.Err).Code == "NotImplemented" { - isVersion = false - break + goto noVersioning } else { contentCh <- &ClientContent{ Err: probe.NewError(objectVersion.Err), @@ -1669,18 +1667,15 @@ func (c *S3Client) List(ctx context.Context, opts ListOptions) <-chan *ClientCon } contentCh <- c.objectInfo2ClientContent(bucket.Name, objectVersion) } - if !isVersion { - c.listRecursiveInRoutine(ctx, contentCh, false) - } } + close(contentCh) + return default: - isVersion := true for objectVersion := range c.listVersions(ctx, b, o, opts.isRecursive, opts.timeRef, opts.withOlderVersions, opts.withDeleteMarkers) { if objectVersion.Err != nil { if minio.ToErrorResponse(objectVersion.Err).Code == "NotImplemented" { - isVersion = false - break + goto noVersioning } else { contentCh <- &ClientContent{ Err: probe.NewError(objectVersion.Err), @@ -1690,11 +1685,11 @@ func (c *S3Client) List(ctx context.Context, opts ListOptions) <-chan *ClientCon } contentCh <- c.objectInfo2ClientContent(b, objectVersion) } - if !isVersion { - c.listRecursiveInRoutine(ctx, contentCh, false) - } + close(contentCh) + return } - close(contentCh) + noVersioning: + c.listRecursiveInRoutine(ctx, contentCh, false) }() return contentCh }