fixed issue where torrents that failed checking would not resume checking when the error was cleared. One side effect of this fix is that it should now be possible to pause checking torrents with the 0.14 branch

This commit is contained in:
Arvid Norberg 2009-01-27 09:18:51 +00:00
parent 3cdf9c87a8
commit 0ba2e2cdbd
3 changed files with 22 additions and 14 deletions

View File

@ -218,8 +218,6 @@ namespace libtorrent
torrent_status::state_t state() const { return m_state; }
void set_state(torrent_status::state_t s);
void clear_error();
session_settings const& settings() const;
aux::session_impl& session() { return m_ses; }
@ -247,7 +245,8 @@ namespace libtorrent
void ip_filter_updated() { m_policy.ip_filter_updated(); }
void set_error(std::string const& msg) { m_error = msg; }
void clear_error();
void set_error(std::string const& msg);
bool has_error() const { return !m_error.empty(); }
void pause();
void resume();

View File

@ -1501,12 +1501,8 @@ namespace aux {
{
--hard_limit;
++total_running;
if (t->state() != torrent_status::queued_for_checking
&& t->state() != torrent_status::checking_files)
{
--num_downloaders;
if (t->is_paused()) t->resume();
}
--num_downloaders;
if (t->is_paused()) t->resume();
}
else
{

View File

@ -580,7 +580,7 @@ namespace libtorrent
if (m_torrent_file->num_pieces()
> piece_picker::max_pieces)
{
m_error = "too many pieces in torrent";
set_error("too many pieces in torrent");
pause();
}
@ -682,7 +682,7 @@ namespace libtorrent
" ]\n";
#endif
}
m_error = j.str;
set_error(j.str);
pause();
set_state(torrent_status::queued_for_checking);
@ -879,7 +879,7 @@ namespace libtorrent
" ]\n";
#endif
}
m_error = j.str;
set_error(j.str);
pause();
return;
}
@ -923,7 +923,7 @@ namespace libtorrent
#endif
}
pause();
m_error = j.str;
set_error(j.str);
if (!m_abort) m_ses.done_checking(shared_from_this());
set_state(torrent_status::queued_for_checking);
return;
@ -4338,6 +4338,19 @@ namespace libtorrent
m_ses.check_torrent(shared_from_this());
}
void torrent::set_error(std::string const& msg)
{
bool checking_files = should_check_files();
m_error = msg;
if (checking_files && !should_check_files())
{
// stop checking
m_storage->abort_disk_io();
m_ses.done_checking(shared_from_this());
set_state(torrent_status::queued_for_checking);
}
}
void torrent::auto_managed(bool a)
{
INVARIANT_CHECK;
@ -4846,7 +4859,7 @@ namespace libtorrent
{
if (alerts().should_post<file_error_alert>())
alerts().post_alert(file_error_alert(j.error_file, get_handle(), j.str));
m_error = j.str;
set_error(j.str);
pause();
}
f(ret);