fix end-game mode when filtering pieces (i.e. deselecting files for download)

This commit is contained in:
Arvid Norberg 2012-06-24 20:57:31 +00:00
parent 3f1bfb5477
commit 142786d6ed
2 changed files with 10 additions and 2 deletions

View File

@ -329,6 +329,8 @@ namespace libtorrent
std::vector<downloading_piece> const& get_download_queue() const
{ return m_downloads; }
int num_downloading_pieces() const { return int(m_downloads.size()); }
void* get_downloader(piece_block block) const;
// the number of filtered pieces we don't have

View File

@ -236,9 +236,15 @@ namespace libtorrent
// and we're not strictly speaking in end-game mode yet
// also, if we already have at least one outstanding
// request, we shouldn't pick any busy pieces either
// the number of pieces we want (i.e. not including the filtered pieces)
int num_want = t.torrent_file().num_pieces() - p.num_filtered();
// the number of pieces we already have (not counting pieces that are filtered
// that we might have still for some reason)
int num_have = p.num_have() - p.num_have_filtered();
bool dont_pick_busy_blocks = (ses.m_settings.strict_end_game_mode
&& p.num_have() + int(p.get_download_queue().size())
< t.torrent_file().num_pieces())
&& num_have + p.num_downloading_pieces() < num_want)
|| dq.size() + rq.size() > 0;
// this is filled with an interesting piece