feat: http downloader

This commit is contained in:
liwei committed 2020-08-03 18:35:50 +08:00
1 parent 15e5d2af3b
commit 788376eaa9
22 files changed
+813 -64

No files matched your search

+2 -1
View File
@@ -324,7 +324,7 @@ func (pc *peerConn) handlePiece(buf []byte) {
fileWritable := f.End - blockFileBegin
// 计算block剩余写入字节数
blockWritable := blockLength - blockSeek
fb := fileBlock{
fb := &fileBlock{
filepath: filepath.Join(f.Path...),
fileSeek: blockFileBegin - f.Begin,
blockBegin: blockSeek,
@@ -420,6 +420,7 @@ func (pc *peerConn) handlePiece(buf []byte) {
}
// 获取piece对应要写入的文件
// TODO 使用sort.Search二分查找法检索
func getWriteFile(pieceBegin int64, fds []*metainfo.FileDetail) int {
for i, f := range fds {
if f.Begin <= pieceBegin && f.End > pieceBegin {