fix wanted_done/done accounting when force-rechecking

This commit is contained in:
arvidn
2022-09-07 20:19:16 +02:00
committed by Arvid Norberg
parent 60ab38b351
commit 544b617d4c
3 changed files with 18 additions and 1 deletions

View File

@ -1,3 +1,4 @@
* fix wanted_done/done accounting when force-rechecking
* expose userdata via torrent_handle (back-port from 2.0)
* fix renaming of filenames that are too long for the filesystem
* made UPnP and LSD code avoid using select_reactor (to work around an issue on windows in boost.asio < 1.80)

View File

@ -173,7 +173,7 @@ namespace libtorrent {
m_num_have_filtered = 0;
m_num_have = 0;
m_have_pad_blocks = 0;
m_filtered_pad_blocks = 0;
m_filtered_pad_blocks += m_have_filtered_pad_blocks;
m_have_filtered_pad_blocks = 0;
m_num_passed = 0;
m_dirty = true;

View File

@ -612,27 +612,43 @@ TORRENT_TEST(resize)
{
// make sure init preserves priorities
auto p = setup_picker("1111111", " ", "1111111", "");
p->mark_as_pad({piece_index_t(0), 1});
p->mark_as_pad({piece_index_t(2), 1});
p->mark_as_pad({piece_index_t(2), 2});
TEST_EQUAL(p->want().num_pieces, 7);
TEST_EQUAL(p->want().pad_blocks, 3);
TEST_EQUAL(p->have_want().num_pieces, 0);
TEST_EQUAL(p->have_want().pad_blocks, 0);
TEST_EQUAL(p->have().num_pieces, 0);
TEST_EQUAL(p->have().pad_blocks, 0);
p->set_piece_priority(piece_index_t(0), dont_download);
TEST_EQUAL(p->want().num_pieces, 6);
TEST_EQUAL(p->want().pad_blocks, 2);
TEST_EQUAL(p->have_want().num_pieces, 0);
TEST_EQUAL(p->have_want().pad_blocks, 0);
TEST_EQUAL(p->have().num_pieces, 0);
TEST_EQUAL(p->have().pad_blocks, 0);
p->we_have(piece_index_t(0));
TEST_EQUAL(p->want().num_pieces, 6);
TEST_EQUAL(p->want().pad_blocks, 2);
TEST_EQUAL(p->have_want().num_pieces, 0);
TEST_EQUAL(p->have_want().pad_blocks, 0);
TEST_EQUAL(p->have().num_pieces, 1);
TEST_EQUAL(p->have().pad_blocks, 1);
// the piece priority is expected to be preserved
p->resize(blocks_per_piece, blocks_per_piece, blocks_per_piece * 7);
TEST_EQUAL(p->piece_priority(piece_index_t(0)), dont_download);
TEST_EQUAL(p->want().num_pieces, blocks_per_piece * 7 - 1);
TEST_EQUAL(p->want().pad_blocks, 2);
TEST_EQUAL(p->have_want().num_pieces, 0);
TEST_EQUAL(p->have_want().pad_blocks, 0);
TEST_EQUAL(p->have().num_pieces, 0);
TEST_EQUAL(p->have().pad_blocks, 0);
}
TORRENT_TEST(we_have_all)