diff --git a/ChangeLog b/ChangeLog index 76c021f41..41057ebff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -56,6 +56,8 @@ release 0.14.2 wrong order, for encrypted connections. * fixed race condition where torrents could get stuck waiting to get checked + * fixed mapped files bug where it wouldn't be properly restored + from resume data properly release 0.14.1 diff --git a/src/torrent.cpp b/src/torrent.cpp index 349c48dfe..f555fc980 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -1867,6 +1867,9 @@ namespace libtorrent dequeue_torrent_check(); + if (m_state == torrent_status::checking_files) + set_state(torrent_status::queued_for_checking); + m_owning_storage = 0; m_host_resolver.cancel(); } @@ -2978,7 +2981,7 @@ namespace libtorrent { std::string new_filename = mapped_files->list_string_value_at(i); if (new_filename.empty()) continue; - m_torrent_file->rename_file(i, new_filename); + rename_file(i, new_filename); } } diff --git a/test/test_storage.cpp b/test/test_storage.cpp index defb5527b..e4c20f82d 100644 --- a/test/test_storage.cpp +++ b/test/test_storage.cpp @@ -536,13 +536,17 @@ void test_rename_file_in_fastresume(path const& test_path) h.rename_file(0, "testing_renamed_files"); std::cout << "renaming file" << std::endl; + bool renamed = false; for (int i = 0; i < 100; ++i) { - if (print_alerts(ses, "ses", true, true, true, &got_file_rename_alert)) break; + 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; } std::cout << "stop loop" << std::endl; + torrent_status s = h.status(); + TEST_CHECK(s.state == torrent_status::seeding); resume = h.write_resume_data(); ses.remove_torrent(h); } @@ -565,7 +569,12 @@ void test_rename_file_in_fastresume(path const& test_path) } torrent_status stat = h.status(); TEST_CHECK(stat.state == torrent_status::seeding); + + resume = h.write_resume_data(); + ses.remove_torrent(h); } + TEST_CHECK(resume.dict().find("mapped_files") != resume.dict().end()); + resume.print(std::cout); remove_all(test_path / "tmp2"); }