rclone/vendor/storj.io/uplink/private/testuplink/uplink.go
Caleb Case e7bd392a69 backend/tardigrade: Upgrade to uplink v1.0.6
This fixes an important bug with listing that affects users with more
than 500 objects in a listing operation.
2020-05-29 18:00:08 +01:00

23 lines
639 B
Go

// Copyright (C) 2020 Storj Labs, Inc.
// See LICENSE for copying information.
package testuplink
import (
"context"
"storj.io/common/memory"
)
type segmentSizeKey struct{}
// WithMaxSegmentSize creates context with max segment size for testing purposes.
func WithMaxSegmentSize(ctx context.Context, segmentSize memory.Size) context.Context {
return context.WithValue(ctx, segmentSizeKey{}, segmentSize)
}
// GetMaxSegmentSize returns max segment size from context if exists.
func GetMaxSegmentSize(ctx context.Context) (memory.Size, bool) {
segmentSize, ok := ctx.Value(segmentSizeKey{}).(memory.Size)
return segmentSize, ok
}