forked from premiere/premiere-libtorrent
moves force checked torrents to the end of the queue. Fixes #350
This commit is contained in:
parent
9a8fc4f713
commit
6c24bd0774
|
@ -164,6 +164,8 @@ namespace libtorrent
|
||||||
void abort();
|
void abort();
|
||||||
bool is_aborted() const { return m_abort; }
|
bool is_aborted() const { return m_abort; }
|
||||||
|
|
||||||
|
torrent_status::state_t state() const { return m_state; }
|
||||||
|
|
||||||
session_settings const& settings() const;
|
session_settings const& settings() const;
|
||||||
|
|
||||||
aux::session_impl& session() { return m_ses; }
|
aux::session_impl& session() { return m_ses; }
|
||||||
|
|
|
@ -1352,7 +1352,9 @@ namespace aux {
|
||||||
, end(downloaders.end()); i != end; ++i)
|
, end(downloaders.end()); i != end; ++i)
|
||||||
{
|
{
|
||||||
torrent* t = *i;
|
torrent* t = *i;
|
||||||
if (num_downloaders > 0)
|
if (num_downloaders > 0
|
||||||
|
&& t->state() != queued_for_checking
|
||||||
|
&& t->state() != checking_files)
|
||||||
{
|
{
|
||||||
--num_downloaders;
|
--num_downloaders;
|
||||||
--num_seeds;
|
--num_seeds;
|
||||||
|
|
|
@ -632,6 +632,7 @@ namespace libtorrent
|
||||||
// assume that we don't have anything
|
// assume that we don't have anything
|
||||||
m_files_checked = false;
|
m_files_checked = false;
|
||||||
m_state = torrent_status::queued_for_checking;
|
m_state = torrent_status::queued_for_checking;
|
||||||
|
set_queue_position((std::numeric_limits<int>::max)());
|
||||||
|
|
||||||
m_resume_data = entry();
|
m_resume_data = entry();
|
||||||
m_storage->async_check_fastresume(&m_resume_data
|
m_storage->async_check_fastresume(&m_resume_data
|
||||||
|
@ -3393,11 +3394,23 @@ namespace libtorrent
|
||||||
|
|
||||||
void torrent::set_queue_position(int p)
|
void torrent::set_queue_position(int p)
|
||||||
{
|
{
|
||||||
|
TORRENT_ASSERT((p == -1) == is_finished());
|
||||||
if (is_finished() && p != -1) return;
|
if (is_finished() && p != -1) return;
|
||||||
if (p == m_sequence_number) return;
|
if (p == m_sequence_number) return;
|
||||||
|
|
||||||
session_impl::torrent_map& torrents = m_ses.m_torrents;
|
session_impl::torrent_map& torrents = m_ses.m_torrents;
|
||||||
if (p < 0)
|
if (p >= 0 && m_sequence_number == -1)
|
||||||
|
{
|
||||||
|
int max_seq = 0;
|
||||||
|
for (session_impl::torrent_map::iterator i = torrents.begin()
|
||||||
|
, end(torrents.end()); i != end; ++i)
|
||||||
|
{
|
||||||
|
torrent* t = i->second.get();
|
||||||
|
if (t->m_sequence_number > max_seq) max_seq = t->m_sequence_number;
|
||||||
|
}
|
||||||
|
m_sequence_number = (std::min)(max_seq + 1, p);
|
||||||
|
}
|
||||||
|
else if (p < 0)
|
||||||
{
|
{
|
||||||
for (session_impl::torrent_map::iterator i = torrents.begin()
|
for (session_impl::torrent_map::iterator i = torrents.begin()
|
||||||
, end(torrents.end()); i != end; ++i)
|
, end(torrents.end()); i != end; ++i)
|
||||||
|
@ -3436,8 +3449,8 @@ namespace libtorrent
|
||||||
if (t == this) continue;
|
if (t == this) continue;
|
||||||
|
|
||||||
if (pos <= p
|
if (pos <= p
|
||||||
&& pos > m_sequence_number
|
&& pos > m_sequence_number
|
||||||
&& pos != -1)
|
&& pos != -1)
|
||||||
--t->m_sequence_number;
|
--t->m_sequence_number;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue