Skip to content

Commit bb4ff49

Browse files
when --no-list is specified avoid every List() call (#5082)
1 parent 308a8ea commit bb4ff49

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

cmd/client-s3.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1659,18 +1659,21 @@ func (c *S3Client) Stat(ctx context.Context, opts StatOptions) (*ClientContent,
16591659
if opts.isZip {
16601660
o.Set("x-minio-extract", "true")
16611661
}
1662+
16621663
o.Set("x-amz-checksum-mode", "ENABLED")
16631664
ctnt, err := c.getObjectStat(ctx, bucket, path, o)
16641665
if err == nil {
16651666
return ctnt, nil
16661667
}
1668+
16671669
// Ignore object missing error but return for other errors
16681670
if !errors.As(err.ToGoError(), &ObjectMissing{}) && !errors.As(err.ToGoError(), &ObjectIsDeleteMarker{}) {
16691671
return nil, err
16701672
}
16711673

16721674
// when versionID is specified we do not have to perform List() operation
1673-
if opts.versionID != "" && errors.As(err.ToGoError(), &ObjectMissing{}) || errors.As(err.ToGoError(), &ObjectIsDeleteMarker{}) {
1675+
// when headOnly is specified we do not have to perform List() operation
1676+
if (opts.versionID != "" || opts.headOnly) && errors.As(err.ToGoError(), &ObjectMissing{}) || errors.As(err.ToGoError(), &ObjectIsDeleteMarker{}) {
16741677
return nil, probe.NewError(ObjectMissing{opts.timeRef})
16751678
}
16761679

cmd/client-url.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ func url2Stat(ctx context.Context, opts url2StatOptions) (client Client, content
212212
versionID: opts.versionID,
213213
isZip: opts.isZip,
214214
ignoreBucketExists: opts.ignoreBucketExistsCheck,
215+
headOnly: opts.headOnly,
215216
})
216217
if err != nil {
217218
return nil, nil, err.Trace(opts.urlStr)

cmd/client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ type StatOptions struct {
8888
includeVersions bool
8989
isZip bool
9090
ignoreBucketExists bool
91+
headOnly bool
9192
}
9293

9394
// BucketStatOptions - bucket stat.

0 commit comments

Comments
 (0)