got icon indicating copy to clipboard operation
got copied to clipboard

download file content is not valid if use ChunkSize is bigger than the file content size

Open simonwu-os opened this issue 2 years ago • 0 comments

I use --chunk 5242880 to specify ChunkSize.
If the size of the target file is less then 5M, the content downloaded is not valid. Its sha256 is not right. I check the source code, I find it has a bug. When d.info.Size is less than d.ChunkSize, then chunksLen is zero.

I fix it in my fork https://github.com/simonwu-os/got. It works fine.

chunksLen := d.info.Size / d.ChunkSize ///added by simon wu ///fix if chunksLen = 0, then the result file content is not valid. if chunksLen == 0 { chunksLen += 1 } ///end of added

simonwu-os avatar Dec 24 '22 09:12 simonwu-os