From 4dbd0c851b9b0cb0d8b02c44d72c311a25a2512a Mon Sep 17 00:00:00 2001 From: "weixian.cxy" Date: Sat, 9 Oct 2021 14:39:25 +0800 Subject: [PATCH] fix #6054 MaxConcurrentDownloads is not effect when Unpack is true Signed-off-by: weixian.cxy (cherry picked from commit 535191abf3b3f6a41fe63fc7952f1f72690b2d70) --- unpacker.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/unpacker.go b/unpacker.go index 76f5d7b0c4fb..d9e120dce97f 100644 --- a/unpacker.go +++ b/unpacker.go @@ -65,11 +65,16 @@ func (c *Client) newUnpacker(ctx context.Context, rCtx *RemoteContext) (*unpacke return nil, err } } + var limiter *semaphore.Weighted + if rCtx.MaxConcurrentDownloads > 0 { + limiter = semaphore.NewWeighted(int64(rCtx.MaxConcurrentDownloads)) + } return &unpacker{ updateCh: make(chan ocispec.Descriptor, 128), snapshotter: snapshotter, config: config, c: c, + limiter: limiter, }, nil }