🧱 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.

Cleans up unnecessary code

+1 -6
+1 -6
main.go
··· 94 94 95 95 func (c chunk) size() int64 { return (c.end + 1) - c.start } 96 96 func (c chunk) rangeHeader() string { return fmt.Sprintf("bytes=%d-%d", c.start, c.end) } 97 - func (c chunk) last() bool { return c.end+1 == c.size() } 98 97 99 98 func (d *Downloader) downloadChunkWithContext(ctx context.Context, u string, c chunk) ([]byte, error) { 100 99 req, err := http.NewRequestWithContext(ctx, http.MethodGet, u, nil) ··· 261 260 ch <- s 262 261 return 263 262 } 264 - a := int64(len(b)) 265 - if !c.last() { 266 - a -= 1 // adjust for extra EOF bytes 267 - } 268 - s.DownloadedFileBytes += a 263 + s.DownloadedFileBytes += int64(len(b)) 269 264 ch <- s 270 265 } 271 266 }