Skip to content

Commit d56466c

Browse files
committed
[transfer] avoid setting limiters when max is 0
Signed-off-by: Derek McGowan <[email protected]>
1 parent a7ceac8 commit d56466c

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

pkg/transfer/local/transfer.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,19 @@ type localTransferService struct {
4646
}
4747

4848
func NewTransferService(lm leases.Manager, cs content.Store, is images.Store, tc *TransferConfig) transfer.Transferrer {
49-
return &localTransferService{
50-
leases: lm,
51-
content: cs,
52-
images: is,
53-
limiterU: semaphore.NewWeighted(int64(tc.MaxConcurrentUploadedLayers)),
54-
limiterD: semaphore.NewWeighted(int64(tc.MaxConcurrentDownloads)),
55-
config: *tc,
49+
ts := &localTransferService{
50+
leases: lm,
51+
content: cs,
52+
images: is,
53+
config: *tc,
5654
}
55+
if tc.MaxConcurrentUploadedLayers > 0 {
56+
ts.limiterU = semaphore.NewWeighted(int64(tc.MaxConcurrentUploadedLayers))
57+
}
58+
if tc.MaxConcurrentDownloads > 0 {
59+
ts.limiterD = semaphore.NewWeighted(int64(tc.MaxConcurrentDownloads))
60+
}
61+
return ts
5762
}
5863

5964
func (ts *localTransferService) Transfer(ctx context.Context, src interface{}, dest interface{}, opts ...transfer.Opt) error {

0 commit comments

Comments
 (0)