Problem
downloadChunkWithContext accepts both 206 Partial Content and 200 OK responses to a ranged request (downloader.go:150). A server that ignores the Range header replies 200 OK with the entire file, which is then written at the chunk's offset via WriteAt (downloader.go:386). Every chunk therefore writes the whole file, chunks overlap and corrupt each other, and every chunk is marked as done in the progress file.
Impact
Silent data corruption with no error reported. The final file is much larger than the source and its bytes are wrong, yet the last status has err = nil. Because DownloadedFileBytes can exceed FileSizeBytes, IsFinished() also never returns true.
Reproduction (verified)
- 64 KiB source file → 122,880-byte file on disk, 57,126/65,536 bytes wrong, download reported "success".
- Same behavior through the CLI: 8 MiB source → 16.7 MiB output file.
Suggested fix
Reject 200 OK responses to ranged requests, or validate that the response body length matches the requested chunk size / Content-Range before writing.