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