🧱 Chunk is a download manager for slow and unstable servers
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #30 from cuducos/fix_race

Fixing race condition revealed with new test

authored by

Daniel Fireman and committed by
GitHub
56677d9f 9dd74ab5

+2 -3
+2 -2
downloader.go
··· 251 251 } 252 252 for _, c := range d.chunks(t) { 253 253 urlDownload.Add(1) 254 - go func(c chunk) { 254 + go func(c chunk, s DownloadStatus) { 255 255 defer urlDownload.Done() 256 256 b, err := d.downloadChunk(ctx, url, c) 257 257 if err != nil { ··· 267 267 } 268 268 s.DownloadedFileBytes += int64(n) 269 269 ch <- s 270 - }(c) 270 + }(c, s) 271 271 } 272 272 } 273 273
-1
downloader_test.go
··· 139 139 var got string 140 140 defer os.Remove(got) 141 141 for g := range DefaultDownloader().Download(s.URL + "/archive.zip") { 142 - fmt.Println(g) 143 142 got = g.DownloadedFilePath 144 143 if g.Error != nil { 145 144 t.Errorf("expected no error during the download of the zip archive, got %s", g.Error)