satellite/metainfo/metabase: set maxParts to MaxListLimit if greater

We should set the client requested maxParts to MaxListLimit if it is
greater than that value instead of returning an error.

MinIO default value for maxParts is 10,000 while the satellite's
MaxListLimit is 1,000. If we return an error, the ListParts with default
maxParts will throw an error.

Change-Id: I06739e1d8d8f96803eba491585395da0443aec04
This commit is contained in:
Kaloyan Raev 2020-12-03 13:07:27 +02:00 committed by Fadila
parent fd7cc20a7e
commit a7685f50c9

View File

@ -33,15 +33,11 @@ func (db *DB) ListSegments(ctx context.Context, opts ListSegments) (result ListS
return ListSegmentsResult{}, ErrInvalidRequest.New("StreamID missing") return ListSegmentsResult{}, ErrInvalidRequest.New("StreamID missing")
} }
// TODO verify this limit
if opts.Limit > MaxListLimit {
return ListSegmentsResult{}, ErrInvalidRequest.New("Maximum listing limit is %d", MaxListLimit)
}
if opts.Limit < 0 { if opts.Limit < 0 {
return ListSegmentsResult{}, ErrInvalidRequest.New("Invalid limit: %d", opts.Limit) return ListSegmentsResult{}, ErrInvalidRequest.New("Invalid limit: %d", opts.Limit)
} }
if opts.Limit == 0 { if opts.Limit == 0 || opts.Limit > MaxListLimit {
opts.Limit = MaxListLimit opts.Limit = MaxListLimit
} }