diff --git a/bindings/python/src/torrent_handle.cpp b/bindings/python/src/torrent_handle.cpp index d792ff89d..0e2c5086b 100644 --- a/bindings/python/src/torrent_handle.cpp +++ b/bindings/python/src/torrent_handle.cpp @@ -401,8 +401,6 @@ void bind_torrent_handle() .def("set_priority", _(&torrent_handle::set_priority)) .def("get_torrent_info", &get_torrent_info) .def("super_seeding", super_seeding0) - .def("filter_piece", _(&torrent_handle::filter_piece)) - .def("is_piece_filtered", _(&torrent_handle::is_piece_filtered)) .def("write_resume_data", _(&torrent_handle::write_resume_data)) .def("is_seed", _(&torrent_handle::is_seed)) .def("is_finished", _(&torrent_handle::is_finished)) diff --git a/include/libtorrent/piece_picker.hpp b/include/libtorrent/piece_picker.hpp index a4a9b758f..0f05a448d 100644 --- a/include/libtorrent/piece_picker.hpp +++ b/include/libtorrent/piece_picker.hpp @@ -239,13 +239,6 @@ namespace libtorrent // returns the current piece priorities for all pieces void piece_priorities(std::vector& pieces) const; - // ========== start deprecation ============== - - // fills the bitmask with 1's for pieces that are filtered - void filtered_pieces(std::vector& mask) const; - - // ========== end deprecation ============== - // pieces should be the vector that represents the pieces a // client has. It returns a list of all pieces that this client // has and that are interesting to download. It returns them in diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index d7d737891..9b0e91262 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -515,11 +515,6 @@ namespace libtorrent void peers_erased(std::vector const& peers); // ============ start deprecation ============= - void filter_piece(piece_index_t index, bool filter); - void filter_pieces(std::vector const& bitmask); - bool is_piece_filtered(piece_index_t index) const; - void filtered_pieces(std::vector& bitmask) const; - void filter_files(std::vector const& files); #if !TORRENT_NO_FPU void file_progress_float(aux::vector& fp); #endif diff --git a/include/libtorrent/torrent_handle.hpp b/include/libtorrent/torrent_handle.hpp index 2ee73d20c..bb5581998 100644 --- a/include/libtorrent/torrent_handle.hpp +++ b/include/libtorrent/torrent_handle.hpp @@ -940,24 +940,6 @@ namespace libtorrent TORRENT_DEPRECATED bool super_seeding() const; - // deprecated in 0.13 - // all these are deprecated, use piece - // priority functions instead - // marks the piece with the given index as filtered - // it will not be downloaded - TORRENT_DEPRECATED - void filter_piece(piece_index_t index, bool filter) const; - TORRENT_DEPRECATED - void filter_pieces(std::vector const& pieces) const; - TORRENT_DEPRECATED - bool is_piece_filtered(piece_index_t index) const; - TORRENT_DEPRECATED - std::vector filtered_pieces() const; - // marks the file with the given index as filtered - // it will not be downloaded - TORRENT_DEPRECATED - void filter_files(std::vector const& files) const; - // deprecated in 0.14 // use save_resume_data() instead. It is async. and // will return the resume data in an alert diff --git a/src/piece_picker.cpp b/src/piece_picker.cpp index c5e8fe4aa..82bf586f3 100644 --- a/src/piece_picker.cpp +++ b/src/piece_picker.cpp @@ -1771,21 +1771,6 @@ namespace libtorrent } } - // ============ start deprecation ============== - - void piece_picker::filtered_pieces(std::vector& mask) const - { - mask.resize(m_piece_map.size()); - std::vector::iterator j = mask.begin(); - for (std::vector::const_iterator i = m_piece_map.begin(), - end(m_piece_map.end()); i != end; ++i, ++j) - { - *j = i->filtered(); - } - } - - // ============ end deprecation ============== - namespace { int append_blocks(std::vector& dst, std::vector& src diff --git a/src/torrent.cpp b/src/torrent.cpp index d8daae1bb..ae4c8f278 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -5100,127 +5100,6 @@ namespace libtorrent } } - void torrent::filter_piece(piece_index_t index, bool filter) - { - INVARIANT_CHECK; - - TORRENT_ASSERT(valid_metadata()); - if (is_seed()) return; - need_picker(); - - // this call is only valid on torrents with metadata - TORRENT_ASSERT(index >= piece_index_t(0)); - TORRENT_ASSERT(index < m_torrent_file->end_piece()); - - if (index < piece_index_t(0) || index >= m_torrent_file->end_piece()) - { - return; - } - - bool const was_finished = is_finished(); - m_picker->set_piece_priority(index, filter ? 1 : 0); - update_peer_interest(was_finished); - update_gauge(); - } - - void torrent::filter_pieces(std::vector const& bitmask) - { - INVARIANT_CHECK; - - // this call is only valid on torrents with metadata - TORRENT_ASSERT(valid_metadata()); - if (is_seed()) return; - - need_picker(); - - bool const was_finished = is_finished(); - piece_index_t index(0); - for (auto i = bitmask.begin(), end(bitmask.end()); i != end; ++i, ++index) - { - if ((m_picker->piece_priority(index) == 0) == *i) continue; - if (*i) m_picker->set_piece_priority(index, 0); - else m_picker->set_piece_priority(index, 1); - } - update_peer_interest(was_finished); - update_gauge(); - } - - bool torrent::is_piece_filtered(piece_index_t index) const - { - // this call is only valid on torrents with metadata - TORRENT_ASSERT(valid_metadata()); - if (!has_picker()) return false; - - TORRENT_ASSERT(m_picker.get()); - TORRENT_ASSERT(index >= piece_index_t(0)); - TORRENT_ASSERT(index < m_torrent_file->end_piece()); - - if (index < piece_index_t(0) || index >= m_torrent_file->end_piece()) - { - return true; - } - - return m_picker->piece_priority(index) == 0; - } - - void torrent::filtered_pieces(std::vector& bitmask) const - { - INVARIANT_CHECK; - - // this call is only valid on torrents with metadata - TORRENT_ASSERT(valid_metadata()); - if (!has_picker()) - { - bitmask.clear(); - bitmask.resize(m_torrent_file->num_pieces(), false); - return; - } - - TORRENT_ASSERT(m_picker.get()); - m_picker->filtered_pieces(bitmask); - } - - void torrent::filter_files(std::vector const& bitmask) - { - INVARIANT_CHECK; - - // this call is only valid on torrents with metadata - if (!valid_metadata() || is_seed()) return; - - // the bitmask need to have exactly one bit for every file - // in the torrent - TORRENT_ASSERT(int(bitmask.size()) == m_torrent_file->num_files()); - - if (int(bitmask.size()) != m_torrent_file->num_files()) return; - - std::int64_t position = 0; - - if (m_torrent_file->num_pieces()) - { - int piece_length = m_torrent_file->piece_length(); - // mark all pieces as filtered, then clear the bits for files - // that should be downloaded - std::vector piece_filter(m_torrent_file->num_pieces(), true); - for (file_index_t i = file_index_t(0); i < file_index_t(int(bitmask.size())); ++i) - { - std::int64_t start = position; - position += m_torrent_file->files().file_size(i); - // is the file selected for download? - if (!bitmask[static_cast(i)]) - { - // mark all pieces of the file as downloadable - int const start_piece = int(start / piece_length); - int const last_piece = int(position / piece_length); - // if one piece spans several files, we might - // come here several times with the same start_piece, end_piece - std::fill(piece_filter.begin() + start_piece, piece_filter.begin() - + last_piece + 1, false); - } - } - filter_pieces(piece_filter); - } - } - void torrent::replace_trackers(std::vector const& urls) { m_trackers.clear(); diff --git a/src/torrent_handle.cpp b/src/torrent_handle.cpp index 20cfdd4a0..14b4fcd87 100644 --- a/src/torrent_handle.cpp +++ b/src/torrent_handle.cpp @@ -521,35 +521,6 @@ namespace libtorrent return sync_call_ret(false, &torrent::valid_metadata); } - void torrent_handle::filter_piece(piece_index_t index, bool filter) const - { - async_call(&torrent::filter_piece, index, filter); - } - - void torrent_handle::filter_pieces(std::vector const& pieces) const - { - async_call(&torrent::filter_pieces, pieces); - } - - bool torrent_handle::is_piece_filtered(piece_index_t index) const - { - return sync_call_ret(false, &torrent::is_piece_filtered, index); - } - - std::vector torrent_handle::filtered_pieces() const - { - std::vector ret; - auto retr = std::ref(ret); - sync_call(&torrent::filtered_pieces, retr); - return ret; - } - - void torrent_handle::filter_files(std::vector const& files) const - { - auto filesr= std::ref(files); - async_call(&torrent::filter_files, filesr); - } - bool torrent_handle::super_seeding() const { return sync_call_ret(false, &torrent::super_seeding); diff --git a/test/test_piece_picker.cpp b/test/test_piece_picker.cpp index f66ff9405..03423ab31 100644 --- a/test/test_piece_picker.cpp +++ b/test/test_piece_picker.cpp @@ -1019,12 +1019,6 @@ TORRENT_TEST(piece_priorities) TEST_CHECK(prios.size() == 7); int prio_comp[] = {0, 6, 5, 4, 3, 2, 1}; TEST_CHECK(std::equal(prios.begin(), prios.end(), prio_comp)); - - std::vector filter; - p->filtered_pieces(filter); - TEST_CHECK(prios.size() == 7); - bool filter_comp[] = {true, false, false, false, false, false, false}; - TEST_CHECK(std::equal(filter.begin(), filter.end(), filter_comp)); } TORRENT_TEST(restore_piece)