Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when --no-list is specified avoid every List() call #5082

Merged
merged 1 commit into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion cmd/client-s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -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})
}

Expand Down
1 change: 1 addition & 0 deletions cmd/client-url.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions cmd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ type StatOptions struct {
includeVersions bool
isZip bool
ignoreBucketExists bool
headOnly bool
}

// BucketStatOptions - bucket stat.
Expand Down
Loading