remove long-standing deprecated filter_pieces functions (#1457)

remove long-standing deprecated filter_pieces functions
This commit is contained in:
Arvid Norberg 2016-12-27 12:42:23 -08:00 committed by GitHub
parent b74bdfa7db
commit f1e34dfbd5
8 changed files with 0 additions and 203 deletions

View File

@ -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))

View File

@ -239,13 +239,6 @@ namespace libtorrent
// returns the current piece priorities for all pieces
void piece_priorities(std::vector<int>& pieces) const;
// ========== start deprecation ==============
// fills the bitmask with 1's for pieces that are filtered
void filtered_pieces(std::vector<bool>& 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

View File

@ -515,11 +515,6 @@ namespace libtorrent
void peers_erased(std::vector<torrent_peer*> const& peers);
// ============ start deprecation =============
void filter_piece(piece_index_t index, bool filter);
void filter_pieces(std::vector<bool> const& bitmask);
bool is_piece_filtered(piece_index_t index) const;
void filtered_pieces(std::vector<bool>& bitmask) const;
void filter_files(std::vector<bool> const& files);
#if !TORRENT_NO_FPU
void file_progress_float(aux::vector<float, file_index_t>& fp);
#endif

View File

@ -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<bool> const& pieces) const;
TORRENT_DEPRECATED
bool is_piece_filtered(piece_index_t index) const;
TORRENT_DEPRECATED
std::vector<bool> filtered_pieces() const;
// marks the file with the given index as filtered
// it will not be downloaded
TORRENT_DEPRECATED
void filter_files(std::vector<bool> const& files) const;
// deprecated in 0.14
// use save_resume_data() instead. It is async. and
// will return the resume data in an alert

View File

@ -1771,21 +1771,6 @@ namespace libtorrent
}
}
// ============ start deprecation ==============
void piece_picker::filtered_pieces(std::vector<bool>& mask) const
{
mask.resize(m_piece_map.size());
std::vector<bool>::iterator j = mask.begin();
for (std::vector<piece_pos>::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<piece_block>& dst, std::vector<piece_block>& src

View File

@ -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<bool> 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<bool>& 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<bool> 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<bool> 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<int>(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<announce_entry> const& urls)
{
m_trackers.clear();

View File

@ -521,35 +521,6 @@ namespace libtorrent
return sync_call_ret<bool>(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<bool> const& pieces) const
{
async_call(&torrent::filter_pieces, pieces);
}
bool torrent_handle::is_piece_filtered(piece_index_t index) const
{
return sync_call_ret<bool>(false, &torrent::is_piece_filtered, index);
}
std::vector<bool> torrent_handle::filtered_pieces() const
{
std::vector<bool> ret;
auto retr = std::ref(ret);
sync_call(&torrent::filtered_pieces, retr);
return ret;
}
void torrent_handle::filter_files(std::vector<bool> const& files) const
{
auto filesr= std::ref(files);
async_call(&torrent::filter_files, filesr);
}
bool torrent_handle::super_seeding() const
{
return sync_call_ret<bool>(false, &torrent::super_seeding);

View File

@ -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<bool> 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)