fixed file checking bug where the files on disk wouldn't even be inspected
This commit is contained in:
parent
3b35b2c2e3
commit
db4001e406
|
@ -722,30 +722,46 @@ namespace libtorrent
|
||||||
error = "the number of files in resume data is 0";
|
error = "the number of files in resume data is 0";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_entry const* slots = rd.dict_find_list("slots");
|
|
||||||
if (slots == 0)
|
|
||||||
{
|
|
||||||
error = "missing or invalid 'slots' entry in resume data";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool seed = false;
|
bool seed = false;
|
||||||
|
|
||||||
if (int(slots->list_size()) == m_files.num_pieces())
|
lazy_entry const* slots = rd.dict_find_list("slots");
|
||||||
|
if (slots)
|
||||||
{
|
{
|
||||||
bool seed = true;
|
if (int(slots->list_size()) == m_files.num_pieces())
|
||||||
for (int i = 0; i < slots->list_size(); ++i)
|
|
||||||
{
|
{
|
||||||
lazy_entry const* e = slots->list_at(i);
|
seed = true;
|
||||||
if (e->list_int_value_at(i, -1) >= 0) continue;
|
for (int i = 0; i < slots->list_size(); ++i)
|
||||||
seed = false;
|
{
|
||||||
break;
|
lazy_entry const* e = slots->list_at(i);
|
||||||
|
if (e->list_int_value_at(i, -1) >= 0) continue;
|
||||||
|
seed = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (lazy_entry const* pieces = rd.dict_find_string("pieces"))
|
||||||
|
{
|
||||||
|
if (int(pieces->string_length()) == m_files.num_pieces())
|
||||||
|
{
|
||||||
|
seed = true;
|
||||||
|
char const* p = pieces->string_ptr();
|
||||||
|
for (int i = 0; i < pieces->string_length(); ++i)
|
||||||
|
{
|
||||||
|
if ((p[i] & 1) == 1) continue;
|
||||||
|
seed = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
error = "missing 'slots' and 'pieces' entry in resume data";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool full_allocation_mode = false;
|
bool full_allocation_mode = false;
|
||||||
if (rd.dict_find_string_value("allocation") == "full")
|
if (rd.dict_find_string_value("allocation") != "compact")
|
||||||
full_allocation_mode = true;
|
full_allocation_mode = true;
|
||||||
|
|
||||||
if (seed)
|
if (seed)
|
||||||
|
@ -1722,6 +1738,7 @@ namespace libtorrent
|
||||||
m_unallocated_slots.clear();
|
m_unallocated_slots.clear();
|
||||||
m_free_slots.clear();
|
m_free_slots.clear();
|
||||||
}
|
}
|
||||||
|
TORRENT_ASSERT(int(m_piece_to_slot.size()) == m_files.num_pieces());
|
||||||
return need_full_check;
|
return need_full_check;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1801,6 +1818,9 @@ namespace libtorrent
|
||||||
if (rd.dict_find_string_value("allocation") != "compact")
|
if (rd.dict_find_string_value("allocation") != "compact")
|
||||||
storage_mode = storage_mode_sparse;
|
storage_mode = storage_mode_sparse;
|
||||||
|
|
||||||
|
if (!m_storage->verify_resume_data(rd, error))
|
||||||
|
return check_no_fastresume(error);
|
||||||
|
|
||||||
// assume no piece is out of place (i.e. in a slot
|
// assume no piece is out of place (i.e. in a slot
|
||||||
// other than the one it should be in)
|
// other than the one it should be in)
|
||||||
bool out_of_place = false;
|
bool out_of_place = false;
|
||||||
|
@ -1886,9 +1906,6 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_storage->verify_resume_data(rd, error))
|
|
||||||
return check_no_fastresume(error);
|
|
||||||
|
|
||||||
// This will corrupt the storage
|
// This will corrupt the storage
|
||||||
// use while debugging to find
|
// use while debugging to find
|
||||||
// states that cannot be scanned
|
// states that cannot be scanned
|
||||||
|
@ -1911,6 +1928,7 @@ namespace libtorrent
|
||||||
m_state = state_expand_pieces;
|
m_state = state_expand_pieces;
|
||||||
m_current_slot = 0;
|
m_current_slot = 0;
|
||||||
error = "pieces needs to be reordered";
|
error = "pieces needs to be reordered";
|
||||||
|
TORRENT_ASSERT(int(m_piece_to_slot.size()) == m_files.num_pieces());
|
||||||
return need_full_check;
|
return need_full_check;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2028,6 +2046,7 @@ namespace libtorrent
|
||||||
if (other_piece >= 0)
|
if (other_piece >= 0)
|
||||||
m_scratch_buffer.swap(m_scratch_buffer2);
|
m_scratch_buffer.swap(m_scratch_buffer2);
|
||||||
|
|
||||||
|
TORRENT_ASSERT(int(m_piece_to_slot.size()) == m_files.num_pieces());
|
||||||
return need_full_check;
|
return need_full_check;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2074,6 +2093,7 @@ namespace libtorrent
|
||||||
m_slot_to_piece[m_current_slot] = unassigned;
|
m_slot_to_piece[m_current_slot] = unassigned;
|
||||||
m_slot_to_piece[piece] = piece;
|
m_slot_to_piece[piece] = piece;
|
||||||
|
|
||||||
|
TORRENT_ASSERT(int(m_piece_to_slot.size()) == m_files.num_pieces());
|
||||||
return need_full_check;
|
return need_full_check;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2153,6 +2173,7 @@ namespace libtorrent
|
||||||
m_state = state_expand_pieces;
|
m_state = state_expand_pieces;
|
||||||
m_current_slot = 0;
|
m_current_slot = 0;
|
||||||
current_slot = m_current_slot;
|
current_slot = m_current_slot;
|
||||||
|
TORRENT_ASSERT(int(m_piece_to_slot.size()) == m_files.num_pieces());
|
||||||
return need_full_check;
|
return need_full_check;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2162,6 +2183,8 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
return check_init_storage(error);
|
return check_init_storage(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TORRENT_ASSERT(int(m_piece_to_slot.size()) == m_files.num_pieces());
|
||||||
return need_full_check;
|
return need_full_check;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue