mirror of
https://github.com/minio/mc.git
synced 2025-11-28 08:03:56 +03:00
when --no-list is specified avoid every List() call (#5082)
This commit is contained in:
@@ -1659,18 +1659,21 @@ func (c *S3Client) Stat(ctx context.Context, opts StatOptions) (*ClientContent,
|
|||||||
if opts.isZip {
|
if opts.isZip {
|
||||||
o.Set("x-minio-extract", "true")
|
o.Set("x-minio-extract", "true")
|
||||||
}
|
}
|
||||||
|
|
||||||
o.Set("x-amz-checksum-mode", "ENABLED")
|
o.Set("x-amz-checksum-mode", "ENABLED")
|
||||||
ctnt, err := c.getObjectStat(ctx, bucket, path, o)
|
ctnt, err := c.getObjectStat(ctx, bucket, path, o)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return ctnt, nil
|
return ctnt, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ignore object missing error but return for other errors
|
// Ignore object missing error but return for other errors
|
||||||
if !errors.As(err.ToGoError(), &ObjectMissing{}) && !errors.As(err.ToGoError(), &ObjectIsDeleteMarker{}) {
|
if !errors.As(err.ToGoError(), &ObjectMissing{}) && !errors.As(err.ToGoError(), &ObjectIsDeleteMarker{}) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// when versionID is specified we do not have to perform List() operation
|
// 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})
|
return nil, probe.NewError(ObjectMissing{opts.timeRef})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -212,6 +212,7 @@ func url2Stat(ctx context.Context, opts url2StatOptions) (client Client, content
|
|||||||
versionID: opts.versionID,
|
versionID: opts.versionID,
|
||||||
isZip: opts.isZip,
|
isZip: opts.isZip,
|
||||||
ignoreBucketExists: opts.ignoreBucketExistsCheck,
|
ignoreBucketExists: opts.ignoreBucketExistsCheck,
|
||||||
|
headOnly: opts.headOnly,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err.Trace(opts.urlStr)
|
return nil, nil, err.Trace(opts.urlStr)
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ type StatOptions struct {
|
|||||||
includeVersions bool
|
includeVersions bool
|
||||||
isZip bool
|
isZip bool
|
||||||
ignoreBucketExists bool
|
ignoreBucketExists bool
|
||||||
|
headOnly bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// BucketStatOptions - bucket stat.
|
// BucketStatOptions - bucket stat.
|
||||||
|
|||||||
Reference in New Issue
Block a user