diff --git a/ChangeLog b/ChangeLog index 63eaf98a9..973fa4f1b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -74,6 +74,8 @@ * resume data no longer has timestamps of files * require C++11 to build libtorrent + * fix inconsistency in file_priorities and override_resume_data behavior + 1.1.4 release * corrected missing const qualifiers on bdecode_node diff --git a/include/libtorrent/add_torrent_params.hpp b/include/libtorrent/add_torrent_params.hpp index f1b04dd39..3e42d1bc2 100644 --- a/include/libtorrent/add_torrent_params.hpp +++ b/include/libtorrent/add_torrent_params.hpp @@ -234,8 +234,7 @@ namespace libtorrent { // add_torrent_params configuring the torrent override the corresponding // configuration from the resume file, with the one exception of save // resume data, which has its own flag (for historic reasons). - // If this flag is set, but file_priorities is empty, file priorities - // are still loaded from the resume data, if present. + // "file_priorities" and "save_path" are not affected by this flag. flag_override_resume_data TORRENT_DEPRECATED_ENUM = 0x20000, // defaults to on and specifies whether tracker URLs loaded from @@ -335,7 +334,9 @@ namespace libtorrent { // can be set to control the initial file priorities when adding a // torrent. The semantics are the same as for - // ``torrent_handle::prioritize_files()``. + // ``torrent_handle::prioritize_files()``. The file priorities specified + // in here take precedence over those specified in the resume data, if + // any. aux::noexcept_movable> file_priorities; // torrent extension construction functions can be added to this vector diff --git a/include/libtorrent/export.hpp b/include/libtorrent/export.hpp index 87536af2a..503afe27a 100644 --- a/include/libtorrent/export.hpp +++ b/include/libtorrent/export.hpp @@ -33,19 +33,7 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_EXPORT_HPP_INCLUDED #define TORRENT_EXPORT_HPP_INCLUDED -#if !defined(BOOST_COMPILER_CONFIG) && !defined(BOOST_NO_COMPILER_CONFIG) -# include -#endif -#ifdef BOOST_COMPILER_CONFIG -# include BOOST_COMPILER_CONFIG -#endif - -#if !defined(BOOST_PLATFORM_CONFIG) && !defined(BOOST_NO_PLATFORM_CONFIG) -# include -#endif -#ifdef BOOST_PLATFORM_CONFIG -# include BOOST_PLATFORM_CONFIG -#endif +#include // backwards compatibility with older versions of boost #if !defined BOOST_SYMBOL_EXPORT && !defined BOOST_SYMBOL_IMPORT diff --git a/src/torrent.cpp b/src/torrent.cpp index 3bcfbbed2..10bb6ab53 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -4940,7 +4940,7 @@ namespace libtorrent { if (m_torrent_file->num_pieces() > 0 && m_storage) { m_ses.disk_thread().async_set_file_priority(m_storage - , m_file_priority, std::bind(&torrent::on_file_priority, this, _1)); + , m_file_priority, std::bind(&torrent::on_file_priority, shared_from_this(), _1)); } update_piece_priorities(); @@ -4979,7 +4979,7 @@ namespace libtorrent { if (m_storage) { m_ses.disk_thread().async_set_file_priority(m_storage - , m_file_priority, std::bind(&torrent::on_file_priority, this, _1)); + , m_file_priority, std::bind(&torrent::on_file_priority, shared_from_this(), _1)); } update_piece_priorities(); } diff --git a/test/test_resume.cpp b/test/test_resume.cpp index ccf9c6b82..6c667e524 100644 --- a/test/test_resume.cpp +++ b/test/test_resume.cpp @@ -290,6 +290,45 @@ TORRENT_TEST(file_priorities_default_deprecated) TEST_EQUAL(file_priorities[2], 4); } +// As long as the add_torrent_params priorities are empty, the file_priorities +// from the resume data should take effect +TORRENT_TEST(file_priorities_in_resume_deprecated) +{ + lt::session ses(settings()); + std::vector file_priorities = test_resume_flags(ses, 0, "", "123").file_priorities(); + + TEST_EQUAL(file_priorities.size(), 3); + TEST_EQUAL(file_priorities[0], 1); + TEST_EQUAL(file_priorities[1], 2); + TEST_EQUAL(file_priorities[2], 3); +} + +// if both resume data and add_torrent_params has file_priorities, the +// add_torrent_params one take precedence +TORRENT_TEST(file_priorities_in_resume_and_params_deprecated) +{ + lt::session ses(settings()); + std::vector file_priorities = test_resume_flags(ses, 0, "456", "123").file_priorities(); + + TEST_EQUAL(file_priorities.size(), 3); + TEST_EQUAL(file_priorities[0], 4); + TEST_EQUAL(file_priorities[1], 5); + TEST_EQUAL(file_priorities[2], 6); +} + +// if we set flag_override_resume_data, it should no affect file priorities +TORRENT_TEST(file_priorities_override_resume_deprecated) +{ + lt::session ses(settings()); + std::vector file_priorities = test_resume_flags(ses + , add_torrent_params::flag_override_resume_data, "", "123").file_priorities(); + + TEST_EQUAL(file_priorities.size(), 3); + TEST_EQUAL(file_priorities[0], 1); + TEST_EQUAL(file_priorities[1], 2); + TEST_EQUAL(file_priorities[2], 3); +} + TORRENT_TEST(file_priorities_resume_seed_mode_deprecated) { // in share mode file priorities should always be 0