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:
Arvid Norberg 2012-02-19 19:00:52 +00:00
parent 3276167b85
commit 065d75b02d
2 changed files with 18 additions and 1 deletions

View File

@ -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)

View File

@ -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();