fixed new storage
This commit is contained in:
parent
3e5e004e36
commit
1313e32954
|
@ -1635,16 +1635,22 @@ namespace libtorrent {
|
||||||
&large_digest, &small_digest
|
&large_digest, &small_digest
|
||||||
};
|
};
|
||||||
|
|
||||||
bool found = false;
|
int found_piece = -1;
|
||||||
|
|
||||||
for (int i = 0; i < m_info.num_pieces(); ++i)
|
for (int i = 0; i < m_info.num_pieces(); ++i)
|
||||||
{
|
{
|
||||||
|
if (i > current_piece)
|
||||||
|
break;
|
||||||
|
|
||||||
if (pieces[i])
|
if (pieces[i])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const sha1_hash& hash = digest[
|
const sha1_hash& hash = digest[
|
||||||
i == m_info.num_pieces() - 1]->get();
|
i == m_info.num_pieces() - 1]->get();
|
||||||
|
|
||||||
|
if (hash == m_info.hash_for_piece(i))
|
||||||
|
found_piece = i;
|
||||||
|
/*
|
||||||
if (hash == m_info.hash_for_piece(i))
|
if (hash == m_info.hash_for_piece(i))
|
||||||
{
|
{
|
||||||
m_bytes_left -= m_info.piece_size(i);
|
m_bytes_left -= m_info.piece_size(i);
|
||||||
|
@ -1654,10 +1660,18 @@ namespace libtorrent {
|
||||||
pieces[i] = true;
|
pieces[i] = true;
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found)
|
if (found_piece != -1)
|
||||||
|
{
|
||||||
|
m_bytes_left -= m_info.piece_size(found_piece);
|
||||||
|
|
||||||
|
m_piece_to_slot[found_piece] = current_piece;
|
||||||
|
m_slot_to_piece[current_piece] = found_piece;
|
||||||
|
pieces[found_piece] = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
m_slot_to_piece[current_piece] = -2;
|
m_slot_to_piece[current_piece] = -2;
|
||||||
|
|
||||||
|
|
|
@ -512,6 +512,11 @@ namespace libtorrent
|
||||||
boost::mutex& mutex)
|
boost::mutex& mutex)
|
||||||
{
|
{
|
||||||
m_storage.check_pieces(mutex, data, m_have_pieces);
|
m_storage.check_pieces(mutex, data, m_have_pieces);
|
||||||
|
m_num_pieces = std::accumulate(
|
||||||
|
m_have_pieces.begin()
|
||||||
|
, m_have_pieces.end()
|
||||||
|
, 0);
|
||||||
|
|
||||||
m_picker.files_checked(m_have_pieces);
|
m_picker.files_checked(m_have_pieces);
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
m_picker.integrity_check(this);
|
m_picker.integrity_check(this);
|
||||||
|
|
Loading…
Reference in New Issue