fixed file checking bug

This commit is contained in:
Arvid Norberg 2010-08-23 05:51:12 +00:00
parent 80fbe4d5ef
commit 2736a3b7ff
3 changed files with 14 additions and 26 deletions

View File

@ -2344,6 +2344,7 @@ ret:
} }
TORRENT_ASSERT(m_state == state_full_check); TORRENT_ASSERT(m_state == state_full_check);
if (m_state == state_finished) return 0;
int skip = check_one_piece(have_piece); int skip = check_one_piece(have_piece);
TORRENT_ASSERT(m_current_slot <= m_files.num_pieces()); TORRENT_ASSERT(m_current_slot <= m_files.num_pieces());

View File

@ -1039,17 +1039,24 @@ namespace libtorrent
} }
} }
if ((j.error || ret != 0) && m_ses.m_alerts.should_post<fastresume_rejected_alert>()) // only report this error if the user actually provided resume data
if ((j.error || ret != 0) && !m_resume_data.empty()
&& m_ses.m_alerts.should_post<fastresume_rejected_alert>())
{ {
m_ses.m_alerts.post_alert(fastresume_rejected_alert(get_handle(), j.error)); m_ses.m_alerts.post_alert(fastresume_rejected_alert(get_handle(), j.error));
} }
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
(*m_ses.m_logger) << "fastresume data for " (*m_ses.m_logger) << "fastresume data for "
<< torrent_file().name() << " rejected: " << torrent_file().name() << " rejected: "
<< j.error.message() << " ret:" << ret << "\n"; << j.error.message() << " ret:" << ret << "\n";
#endif #endif
if (ret == 0 && !j.error) // if ret != 0, it means we need a full check. We don't necessarily need
// that when the resume data check fails. For instance, if the resume data
// is incorrect, but we don't have any files, we skip the check and initialize
// the storage to not have anything.
if (ret == 0)
{ {
// there are either no files for this torrent // there are either no files for this torrent
// or the resume_data was accepted // or the resume_data was accepted

View File

@ -522,21 +522,11 @@ void run_storage_tests(boost::intrusive_ptr<torrent_info> info
lazy_entry frd; lazy_entry frd;
pm->async_check_fastresume(&frd, boost::bind(&on_check_resume_data, _1, _2, &done)); pm->async_check_fastresume(&frd, boost::bind(&on_check_resume_data, _1, _2, &done));
ios.reset(); ios.reset();
while (!done) run_until(ios, done);
{
ios.reset();
ios.run_one(ec);
if (ec) std::cerr << "run_one: " << ec.message() << std::endl;
}
done = false; done = false;
pm->async_check_files(boost::bind(&on_check_files, _1, _2, &done)); pm->async_check_files(boost::bind(&on_check_files, _1, _2, &done));
while (!done) run_until(ios, done);
{
ios.reset();
ios.run_one(ec);
if (ec) std::cerr << "run_one: " << ec.message() << std::endl;
}
done = false; done = false;
peer_request r; peer_request r;
@ -544,12 +534,7 @@ void run_storage_tests(boost::intrusive_ptr<torrent_info> info
r.start = 10; r.start = 10;
r.length = 16 * 1024; r.length = 16 * 1024;
pm->async_read(r, boost::bind(&on_read, _1, _2, &done)); pm->async_read(r, boost::bind(&on_read, _1, _2, &done));
while (!done) run_until(ios, done);
{
ios.reset();
ios.run_one(ec);
if (ec) std::cerr << "run_one: " << ec.message() << std::endl;
}
// test rename_file // test rename_file
remove(combine_path(test_path, "part0"), ec); remove(combine_path(test_path, "part0"), ec);
@ -739,12 +724,7 @@ void test_check_files(std::string const& test_path
lazy_entry frd; lazy_entry frd;
pm->async_check_fastresume(&frd, boost::bind(&on_check_resume_data, _1, _2, &done)); pm->async_check_fastresume(&frd, boost::bind(&on_check_resume_data, _1, _2, &done));
ios.reset(); ios.reset();
while (!done) run_until(ios, done);
{
ios.reset();
ios.run_one(ec);
if (ec) std::cerr << "run_one: " << ec.message() << std::endl;
}
bool pieces[4] = {false, false, false, false}; bool pieces[4] = {false, false, false, false};
done = false; done = false;