fix inconsistency in file_priorities and override_resume_data behavior. file_priorities are not subject to the override_resume_data flag
This commit is contained in:
parent
7eb3cf6bc6
commit
cc30434c52
|
@ -1,3 +1,5 @@
|
||||||
|
* fix inconsistency in file_priorities and override_resume_data behavior
|
||||||
|
|
||||||
1.1.4 release
|
1.1.4 release
|
||||||
|
|
||||||
* corrected missing const qualifiers on bdecode_node
|
* corrected missing const qualifiers on bdecode_node
|
||||||
|
|
|
@ -157,8 +157,7 @@ namespace libtorrent
|
||||||
// add_torrent_params configuring the torrent override the corresponding
|
// add_torrent_params configuring the torrent override the corresponding
|
||||||
// configuration from the resume file, with the one exception of save
|
// configuration from the resume file, with the one exception of save
|
||||||
// resume data, which has its own flag (for historic reasons).
|
// resume data, which has its own flag (for historic reasons).
|
||||||
// If this flag is set, but file_priorities is empty, file priorities
|
// "file_priorities" and "save_path" are not affected by this flag.
|
||||||
// are still loaded from the resume data, if present.
|
|
||||||
flag_override_resume_data = 0x002,
|
flag_override_resume_data = 0x002,
|
||||||
|
|
||||||
// If ``flag_upload_mode`` is set, the torrent will be initialized in
|
// If ``flag_upload_mode`` is set, the torrent will be initialized in
|
||||||
|
@ -347,7 +346,9 @@ namespace libtorrent
|
||||||
|
|
||||||
// can be set to control the initial file priorities when adding a
|
// can be set to control the initial file priorities when adding a
|
||||||
// torrent. The semantics are the same as for
|
// 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.
|
||||||
std::vector<boost::uint8_t> file_priorities;
|
std::vector<boost::uint8_t> file_priorities;
|
||||||
|
|
||||||
// torrent extension construction functions can be added to this vector
|
// torrent extension construction functions can be added to this vector
|
||||||
|
|
|
@ -5637,7 +5637,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
inc_refcount("file_priority");
|
inc_refcount("file_priority");
|
||||||
m_ses.disk_thread().async_set_file_priority(m_storage.get()
|
m_ses.disk_thread().async_set_file_priority(m_storage.get()
|
||||||
, m_file_priority, boost::bind(&torrent::on_file_priority, this));
|
, m_file_priority, boost::bind(&torrent::on_file_priority, shared_from_this()));
|
||||||
}
|
}
|
||||||
|
|
||||||
update_piece_priorities();
|
update_piece_priorities();
|
||||||
|
@ -5676,7 +5676,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
inc_refcount("file_priority");
|
inc_refcount("file_priority");
|
||||||
m_ses.disk_thread().async_set_file_priority(m_storage.get()
|
m_ses.disk_thread().async_set_file_priority(m_storage.get()
|
||||||
, m_file_priority, boost::bind(&torrent::on_file_priority, this));
|
, m_file_priority, boost::bind(&torrent::on_file_priority, shared_from_this()));
|
||||||
}
|
}
|
||||||
update_piece_priorities();
|
update_piece_priorities();
|
||||||
}
|
}
|
||||||
|
@ -7041,9 +7041,7 @@ namespace libtorrent
|
||||||
if (m_completed_time != 0 && m_completed_time < m_added_time)
|
if (m_completed_time != 0 && m_completed_time < m_added_time)
|
||||||
m_completed_time = m_added_time;
|
m_completed_time = m_added_time;
|
||||||
|
|
||||||
// load file priorities except if the add_torrent_param file was set to
|
if (m_file_priority.empty())
|
||||||
// override resume data
|
|
||||||
if (!m_override_resume_data || m_file_priority.empty())
|
|
||||||
{
|
{
|
||||||
bdecode_node file_priority = rd.dict_find_list("file_priority");
|
bdecode_node file_priority = rd.dict_find_list("file_priority");
|
||||||
if (file_priority)
|
if (file_priority)
|
||||||
|
@ -7071,6 +7069,14 @@ namespace libtorrent
|
||||||
m_file_priority[i] = 0;
|
m_file_priority[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// storage may be NULL during shutdown
|
||||||
|
if (m_storage)
|
||||||
|
{
|
||||||
|
inc_refcount("file_priority");
|
||||||
|
m_ses.disk_thread().async_set_file_priority(m_storage.get()
|
||||||
|
, m_file_priority, boost::bind(&torrent::on_file_priority, shared_from_this()));
|
||||||
|
}
|
||||||
|
|
||||||
update_piece_priorities();
|
update_piece_priorities();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -308,6 +308,45 @@ TORRENT_TEST(file_priorities_default)
|
||||||
TEST_EQUAL(file_priorities[2], 4);
|
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)
|
||||||
|
{
|
||||||
|
lt::session ses(settings());
|
||||||
|
std::vector<int> 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)
|
||||||
|
{
|
||||||
|
lt::session ses(settings());
|
||||||
|
std::vector<int> 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)
|
||||||
|
{
|
||||||
|
lt::session ses(settings());
|
||||||
|
std::vector<int> 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)
|
TORRENT_TEST(file_priorities_resume_seed_mode)
|
||||||
{
|
{
|
||||||
// in share mode file priorities should always be 0
|
// in share mode file priorities should always be 0
|
||||||
|
|
Loading…
Reference in New Issue