From 695cf180f2775ed6cc95c55877fddee5fa729786 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Sun, 17 Nov 2024 00:04:08 -0800 Subject: [PATCH] when --no-list is specified avoid every List() call --- cmd/client-s3.go | 5 ++++- cmd/client-url.go | 1 + cmd/client.go | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/client-s3.go b/cmd/client-s3.go index 1fd4fdab2e..b0c61314ca 100644 --- a/cmd/client-s3.go +++ b/cmd/client-s3.go @@ -1659,18 +1659,21 @@ func (c *S3Client) Stat(ctx context.Context, opts StatOptions) (*ClientContent, if opts.isZip { o.Set("x-minio-extract", "true") } + o.Set("x-amz-checksum-mode", "ENABLED") ctnt, err := c.getObjectStat(ctx, bucket, path, o) if err == nil { return ctnt, nil } + // Ignore object missing error but return for other errors if !errors.As(err.ToGoError(), &ObjectMissing{}) && !errors.As(err.ToGoError(), &ObjectIsDeleteMarker{}) { return nil, err } // when versionID is specified we do not have to perform List() operation - if opts.versionID != "" && errors.As(err.ToGoError(), &ObjectMissing{}) || errors.As(err.ToGoError(), &ObjectIsDeleteMarker{}) { + // when headOnly is specified we do not have to perform List() operation + if (opts.versionID != "" || opts.headOnly) && errors.As(err.ToGoError(), &ObjectMissing{}) || errors.As(err.ToGoError(), &ObjectIsDeleteMarker{}) { return nil, probe.NewError(ObjectMissing{opts.timeRef}) } diff --git a/cmd/client-url.go b/cmd/client-url.go index 30da890ffa..561773bb20 100644 --- a/cmd/client-url.go +++ b/cmd/client-url.go @@ -212,6 +212,7 @@ func url2Stat(ctx context.Context, opts url2StatOptions) (client Client, content versionID: opts.versionID, isZip: opts.isZip, ignoreBucketExists: opts.ignoreBucketExistsCheck, + headOnly: opts.headOnly, }) if err != nil { return nil, nil, err.Trace(opts.urlStr) diff --git a/cmd/client.go b/cmd/client.go index f842deca80..2bb55988a5 100644 --- a/cmd/client.go +++ b/cmd/client.go @@ -88,6 +88,7 @@ type StatOptions struct { includeVersions bool isZip bool ignoreBucketExists bool + headOnly bool } // BucketStatOptions - bucket stat.