forward port fix for bug where dont_count_slow_torrents could not be disabled, into master

This commit is contained in:
arvidn 2015-09-25 14:22:38 -07:00
parent 597be5c1c1
commit 8b30e78d69
3 changed files with 33 additions and 22 deletions

View File

@ -73,6 +73,7 @@
* almost completely changed the storage interface (for custom storage) * almost completely changed the storage interface (for custom storage)
* added support for hashing pieces in multiple threads * added support for hashing pieces in multiple threads
* fix bug where dont_count_slow_torrents could not be disabled
* fix fallocate hack on linux (fixes corruption on some architectures) * fix fallocate hack on linux (fixes corruption on some architectures)
* fix auto-manage bug with announce to tracker/lsd/dht limits * fix auto-manage bug with announce to tracker/lsd/dht limits
* improve DHT routing table to not create an unbalanced tree * improve DHT routing table to not create an unbalanced tree

View File

@ -929,32 +929,13 @@ namespace libtorrent
void add_failed_bytes(int b); void add_failed_bytes(int b);
// this is true if we have all the pieces, but not necessarily flushed them to disk // this is true if we have all the pieces, but not necessarily flushed them to disk
bool is_seed() const bool is_seed() const;
{
if (!valid_metadata()) return false;
if (m_seed_mode) return true;
if (m_have_all) return true;
if (m_picker && m_picker->num_passed() == m_picker->num_pieces()) return true;
return m_state == torrent_status::seeding;
}
// this is true if we have all the pieces that we want // this is true if we have all the pieces that we want
// the pieces don't necessarily need to be flushed to disk // the pieces don't necessarily need to be flushed to disk
bool is_finished() const bool is_finished() const;
{
if (is_seed()) return true;
// this is slightly different from m_picker->is_finished() bool is_inactive() const;
// because any piece that has *passed* is considered here,
// which may be more than the piece we *have* (i.e. written to disk)
// keep in mind that num_filtered() does not include pieces we
// have that are filtered
return valid_metadata() && has_picker()
&& m_torrent_file->num_pieces() - m_picker->num_filtered() - m_picker->num_passed() == 0;
}
bool is_inactive() const
{ return m_inactive; }
std::string save_path() const; std::string save_path() const;
alert_manager& alerts() const; alert_manager& alerts() const;

View File

@ -8623,6 +8623,35 @@ namespace libtorrent
return m_ses.alerts(); return m_ses.alerts();
} }
bool torrent::is_seed() const
{
if (!valid_metadata()) return false;
if (m_seed_mode) return true;
if (m_have_all) return true;
if (m_picker && m_picker->num_passed() == m_picker->num_pieces()) return true;
return m_state == torrent_status::seeding;
}
bool torrent::is_finished() const
{
if (is_seed()) return true;
// this is slightly different from m_picker->is_finished()
// because any piece that has *passed* is considered here,
// which may be more than the piece we *have* (i.e. written to disk)
// keep in mind that num_filtered() does not include pieces we
// have that are filtered
return valid_metadata() && has_picker()
&& m_torrent_file->num_pieces() - m_picker->num_filtered() - m_picker->num_passed() == 0;
}
bool torrent::is_inactive() const
{
if (!settings().get_bool(settings_pack::dont_count_slow_torrents))
return false;
return m_inactive;
}
std::string torrent::save_path() const std::string torrent::save_path() const
{ {
return m_save_path; return m_save_path;