diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index 3372a8d7d..1ec508320 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -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(); diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 89b11ceb9..e13e630e0 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -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 { diff --git a/src/torrent.cpp b/src/torrent.cpp index b92cd0ab9..bade1c155 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -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()) alerts().post_alert(file_error_alert(j.error_file, get_handle(), j.str)); - m_error = j.str; + set_error(j.str); pause(); } f(ret);