diff --git a/src/torrent.cpp b/src/torrent.cpp index 4a2a9550a..2b2609fe8 100755 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -632,29 +632,44 @@ namespace libtorrent m_picker->filtered_pieces(bitmask); } - //idea from Arvid and MooPolice - //todo refactoring and improving the function body + //suggest using this function on filter single file after the downloading progress + //that is after called filter_files function + //or tmp to change a single file filter policy void torrent::filter_file(int index, bool filter) { - __int64 start_position = 0; - int start_piece_index = 0; - int end_piece_index = 0; + // this call is only valid on torrents with metadata + if (!valid_metadata()) return; + try + { + __int64 position = 0, start, piece_length; + int start_piece, end_piece; - for(int i=0;i const& bitmask) { // this call is only valid on torrents with metadata @@ -664,7 +679,7 @@ namespace libtorrent __int64 position = 0, start, piece_length; int start_piece, end_piece; - if (m_torrent_file.num_pieces()) + if (0 < m_torrent_file.num_pieces()) { piece_length = m_torrent_file.piece_length(); std::vector vector_filter_files(m_torrent_file.num_pieces(), false);