@@ -36,9 +36,12 @@ func startCliDownload(url string, contentLength int64, outputFile *os.File) {
3636 ),
3737 mpb .AppendDecorators (decor .Percentage (decor.WC {W : 6 , C : decor .DidentRight })),
3838 )
39- waitGroup .Add (1 )
4039 go cliDownloadChunk (url , workerId , outputFile , offset , progressBar , & waitGroup , & mutex )
40+ waitGroup .Add (1 )
4141 workerId ++
42+ mutex .Lock ()
43+ activeWorkers ++
44+ mutex .Unlock ()
4245 }
4346 waitGroup .Wait ()
4447 progressContainer .Wait ()
@@ -77,9 +80,12 @@ func startDownload(url string, contentLength int64, outputFile *os.File) {
7780 fyne .NewContainerWithLayout (layout .NewFormLayout (), widget .NewLabel (label ), progressBar ),
7881 }
7982 threadContainer .Add (progressBarContainer .container )
80- waitGroup .Add (1 )
8183 go downloadChunk (url , workerId , outputFile , offset , progressBarContainer , & waitGroup , & mutex )
84+ waitGroup .Add (1 )
8285 workerId ++
86+ mutex .Lock ()
87+ activeWorkers ++
88+ mutex .Unlock ()
8389 }
8490 waitGroup .Wait ()
8591 if downloading {
@@ -98,9 +104,6 @@ func cliDownloadChunk(url string, workerId int, outputFile *os.File, offset int6
98104 waitGroup .Done ()
99105 return
100106 }
101- mutex .Lock ()
102- activeWorkers ++
103- mutex .Unlock ()
104107
105108 request , err := http .NewRequest ("GET" , url , nil )
106109 if err != nil {
@@ -153,9 +156,6 @@ func downloadChunk(url string, workerId int, outputFile *os.File, offset int64,
153156 waitGroup .Done ()
154157 return
155158 }
156- mutex .Lock ()
157- activeWorkers ++
158- mutex .Unlock ()
159159
160160 request , err := http .NewRequest ("GET" , url , nil )
161161 if err != nil {
0 commit comments