web seed downloader fix

This commit is contained in:
Arvid Norberg 2007-05-17 19:57:48 +00:00
parent d964abda7a
commit 89d65dcb15
1 changed files with 9 additions and 5 deletions

View File

@ -413,6 +413,8 @@ namespace libtorrent
}
recv_buffer.begin += m_body_start;
// we only received the header, no data
if (recv_buffer.left() == 0) break;
size_type range_start;
size_type range_end;
@ -548,13 +550,15 @@ namespace libtorrent
int copy_size = std::min(std::min(m_requests.front().length - piece_size
, recv_buffer.left()), int(range_end - range_start - m_received_body));
assert(copy_size >= 0);
m_piece.resize(piece_size + copy_size);
if (copy_size > 0)
{
m_piece.resize(piece_size + copy_size);
std::memcpy(&m_piece[0] + piece_size, recv_buffer.begin, copy_size);
recv_buffer.begin += copy_size;
m_received_body += copy_size;
m_body_start += copy_size;
assert(m_received_body <= range_end - range_start);
recv_buffer.begin += copy_size;
m_received_body += copy_size;
m_body_start += copy_size;
}
assert(m_received_body == range_end - range_start);
}
}