forked from premiere/premiere-libtorrent
fix bug in file storage unit test, and the bug causing mapped files to not be restored correctly from resume files
This commit is contained in:
parent
3276167b85
commit
065d75b02d
|
@ -4859,6 +4859,23 @@ namespace libtorrent
|
|||
? m_url : m_uuid, me));
|
||||
}
|
||||
|
||||
// TODO: make this more generic to not just work if files have been
|
||||
// renamed, but also if they have been merged into a single file for instance
|
||||
// maybe use the same format as .torrent files and reuse some code from torrent_info
|
||||
// The mapped_files needs to be read both in the network thread
|
||||
// and in the disk thread, since they both have their own mapped files structures
|
||||
// which are kept in sync
|
||||
lazy_entry const* mapped_files = rd.dict_find_list("mapped_files");
|
||||
if (mapped_files && mapped_files->list_size() == m_torrent_file->num_files())
|
||||
{
|
||||
for (int i = 0; i < m_torrent_file->num_files(); ++i)
|
||||
{
|
||||
std::string new_filename = mapped_files->list_string_value_at(i);
|
||||
if (new_filename.empty()) continue;
|
||||
m_torrent_file->rename_file(i, new_filename);
|
||||
}
|
||||
}
|
||||
|
||||
m_added_time = rd.dict_find_int_value("added_time", m_added_time);
|
||||
m_completed_time = rd.dict_find_int_value("completed_time", m_completed_time);
|
||||
if (m_completed_time != 0 && m_completed_time < m_added_time)
|
||||
|
|
|
@ -975,7 +975,7 @@ void test_rename_file_in_fastresume(std::string const& test_path)
|
|||
if (print_alerts(ses, "ses", true, true, true, &got_file_rename_alert)) renamed = true;
|
||||
test_sleep(1000);
|
||||
torrent_status s = h.status();
|
||||
if (s.state == torrent_status::seeding && renamed) return;
|
||||
if (s.state == torrent_status::seeding && renamed) break;
|
||||
}
|
||||
std::cout << "stop loop" << std::endl;
|
||||
torrent_status s = h.status();
|
||||
|
|
Loading…
Reference in New Issue