[transfer] avoid setting limiters when max is 0

Signed-off-by: Derek McGowan <derek@mcg.dev>
This commit is contained in:
Derek McGowan 2023-05-02 18:17:14 -07:00
parent a7ceac8b63
commit d56466cf39
No known key found for this signature in database
GPG Key ID: F58C5D0A4405ACDB

View File

@ -46,14 +46,19 @@ type localTransferService struct {
}
func NewTransferService(lm leases.Manager, cs content.Store, is images.Store, tc *TransferConfig) transfer.Transferrer {
return &localTransferService{
leases: lm,
content: cs,
images: is,
limiterU: semaphore.NewWeighted(int64(tc.MaxConcurrentUploadedLayers)),
limiterD: semaphore.NewWeighted(int64(tc.MaxConcurrentDownloads)),
config: *tc,
ts := &localTransferService{
leases: lm,
content: cs,
images: is,
config: *tc,
}
if tc.MaxConcurrentUploadedLayers > 0 {
ts.limiterU = semaphore.NewWeighted(int64(tc.MaxConcurrentUploadedLayers))
}
if tc.MaxConcurrentDownloads > 0 {
ts.limiterD = semaphore.NewWeighted(int64(tc.MaxConcurrentDownloads))
}
return ts
}
func (ts *localTransferService) Transfer(ctx context.Context, src interface{}, dest interface{}, opts ...transfer.Opt) error {