diff --git a/ChangeLog b/ChangeLog index c2c9a7b7a..591d6537e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/src/torrent.cpp b/src/torrent.cpp index e22807bb3..1a82dfbae 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -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) diff --git a/test/test_torrent.cpp b/test/test_torrent.cpp index 4740bdc4b..85f1873ba 100644 --- a/test/test_torrent.cpp +++ b/test/test_torrent.cpp @@ -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 buf; bencode(std::back_inserter(buf), t.generate()); boost::shared_ptr ti = boost::make_shared(&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());