fixed file checking bug
This commit is contained in:
parent
80fbe4d5ef
commit
2736a3b7ff
|
@ -2344,6 +2344,7 @@ ret:
|
|||
}
|
||||
|
||||
TORRENT_ASSERT(m_state == state_full_check);
|
||||
if (m_state == state_finished) return 0;
|
||||
|
||||
int skip = check_one_piece(have_piece);
|
||||
TORRENT_ASSERT(m_current_slot <= m_files.num_pieces());
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
||||
(*m_ses.m_logger) << "fastresume data for "
|
||||
<< torrent_file().name() << " rejected: "
|
||||
<< j.error.message() << " ret:" << ret << "\n";
|
||||
#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
|
||||
// or the resume_data was accepted
|
||||
|
|
|
@ -522,21 +522,11 @@ void run_storage_tests(boost::intrusive_ptr<torrent_info> info
|
|||
lazy_entry frd;
|
||||
pm->async_check_fastresume(&frd, boost::bind(&on_check_resume_data, _1, _2, &done));
|
||||
ios.reset();
|
||||
while (!done)
|
||||
{
|
||||
ios.reset();
|
||||
ios.run_one(ec);
|
||||
if (ec) std::cerr << "run_one: " << ec.message() << std::endl;
|
||||
}
|
||||
run_until(ios, done);
|
||||
|
||||
done = false;
|
||||
pm->async_check_files(boost::bind(&on_check_files, _1, _2, &done));
|
||||
while (!done)
|
||||
{
|
||||
ios.reset();
|
||||
ios.run_one(ec);
|
||||
if (ec) std::cerr << "run_one: " << ec.message() << std::endl;
|
||||
}
|
||||
run_until(ios, done);
|
||||
|
||||
done = false;
|
||||
peer_request r;
|
||||
|
@ -544,12 +534,7 @@ void run_storage_tests(boost::intrusive_ptr<torrent_info> info
|
|||
r.start = 10;
|
||||
r.length = 16 * 1024;
|
||||
pm->async_read(r, boost::bind(&on_read, _1, _2, &done));
|
||||
while (!done)
|
||||
{
|
||||
ios.reset();
|
||||
ios.run_one(ec);
|
||||
if (ec) std::cerr << "run_one: " << ec.message() << std::endl;
|
||||
}
|
||||
run_until(ios, done);
|
||||
|
||||
// test rename_file
|
||||
remove(combine_path(test_path, "part0"), ec);
|
||||
|
@ -739,12 +724,7 @@ void test_check_files(std::string const& test_path
|
|||
lazy_entry frd;
|
||||
pm->async_check_fastresume(&frd, boost::bind(&on_check_resume_data, _1, _2, &done));
|
||||
ios.reset();
|
||||
while (!done)
|
||||
{
|
||||
ios.reset();
|
||||
ios.run_one(ec);
|
||||
if (ec) std::cerr << "run_one: " << ec.message() << std::endl;
|
||||
}
|
||||
run_until(ios, done);
|
||||
|
||||
bool pieces[4] = {false, false, false, false};
|
||||
done = false;
|
||||
|
|
Loading…
Reference in New Issue