since the web seed downloader now calls incoming_piece with correct block sizes, incoming piece can be reverted to not allow incorrect block sizes

This commit is contained in:
Arvid Norberg 2006-12-21 11:37:03 +00:00
parent 1b46fb9e1b
commit 755d9f5967
2 changed files with 73 additions and 78 deletions

View File

@ -991,10 +991,10 @@ namespace libtorrent
std::vector<piece_block> finished_blocks;
piece_block block_finished(p.piece, p.start / t->block_size());
bool redundant = true;
for (;block_finished.block_index * t->block_size() < p.start + p.length;
++block_finished.block_index)
{
assert(p.start % t->block_size() == 0);
assert(p.length == t->block_size()
|| p.length == t->torrent_file().total_size() % t->block_size());
std::deque<piece_block>::iterator b
= std::find(
m_download_queue.begin()
@ -1068,21 +1068,16 @@ namespace libtorrent
if (picker.is_finished(block_finished))
{
t->received_redundant_data(t->block_size());
send_block_requests();
return;
}
else
{
redundant = false;
}
fs.write(data, p.piece, p.start, p.length);
picker.mark_as_finished(block_finished, m_remote);
t->get_policy().block_finished(*this, block_finished);
send_block_requests();
}
if (redundant) return;
fs.write(data, p.piece, p.start, p.length);
bool was_seed = t->is_seed();
bool was_finished = picker.num_filtered() + t->num_pieces()

View File

@ -395,7 +395,7 @@ namespace libtorrent
int copy_size = std::min(front_request.length - int(m_piece.size())
, http_body.left());
std::copy(http_body.begin, http_body.begin + copy_size, std::back_inserter(m_piece));
assert(int(m_piece.size() <= front_request.length));
assert(int(m_piece.size()) <= front_request.length);
http_body.begin += copy_size;
int piece_size = int(m_piece.size());
if (piece_size < front_request.length)