fix regression where paused torrents could not have their queue position changed

This commit is contained in:
arvidn 2017-06-25 11:56:19 -04:00 committed by Arvid Norberg
parent ec30a5e9ec
commit 506950001d
3 changed files with 21 additions and 6 deletions

View File

@ -1,3 +1,4 @@
* fix changing queue position of paused torrents (1.1.3 regression)
* fix re-check issue after move_storage
* handle invalid arguments to set_piece_deadline()
* move_storage did not work for torrents without metadata

View File

@ -9308,8 +9308,9 @@ namespace libtorrent
void torrent::queue_up()
{
// fix race conditions on async position change calls (from handler)
if(!m_auto_managed || m_abort || is_finished()) return;
// finished torrents may not change their queue positions, as it's set to
// -1
if (m_abort || is_finished()) return;
set_queue_position(queue_position() == 0
? queue_position() : queue_position() - 1);
@ -9324,8 +9325,9 @@ namespace libtorrent
{
TORRENT_ASSERT(is_single_thread());
// fix race conditions on async position change calls (from handler)
if ((!m_auto_managed || m_abort || is_finished()) && p != -1) return;
// finished torrents may not change their queue positions, as it's set to
// -1
if ((m_abort || is_finished()) && p != -1) return;
TORRENT_ASSERT((p == -1) == is_finished()
|| (!m_auto_managed && p == -1)

View File

@ -393,7 +393,7 @@ TORRENT_TEST(torrent_total_size_zero)
TEST_CHECK(ec);
}
TORRENT_TEST(queue)
void test_queue(add_torrent_params p)
{
lt::settings_pack pack = settings();
// we're not testing the hash check, just accept the data we write
@ -412,7 +412,6 @@ TORRENT_TEST(queue)
std::vector<char> buf;
bencode(std::back_inserter(buf), t.generate());
boost::shared_ptr<torrent_info> ti = boost::make_shared<torrent_info>(&buf[0], buf.size());
add_torrent_params p;
p.ti = ti;
p.save_path = ".";
torrents.push_back(ses.add_torrent(p));
@ -503,6 +502,19 @@ TORRENT_TEST(queue)
TEST_EQUAL(torrents[3].queue_position(), 4);
}
TORRENT_TEST(queue)
{
test_queue(add_torrent_params());
}
TORRENT_TEST(queue_paused)
{
add_torrent_params p;
p.flags |= add_torrent_params::flag_paused;
p.flags &= ~add_torrent_params::flag_auto_managed;
test_queue(p);
}
TORRENT_TEST(test_move_storage_no_metadata)
{
lt::session ses(settings());