diff --git a/bindings/python/src/torrent_handle.cpp b/bindings/python/src/torrent_handle.cpp index 09e6d8d10..343ef27bb 100644 --- a/bindings/python/src/torrent_handle.cpp +++ b/bindings/python/src/torrent_handle.cpp @@ -267,6 +267,7 @@ void bind_torrent_handle() .def("is_paused", _(&torrent_handle::is_paused)) .def("pause", _(&torrent_handle::pause)) .def("resume", _(&torrent_handle::resume)) + .def("clear_error", _(&torrent_handle::clear_error)) .def("is_auto_managed", _(&torrent_handle::is_auto_managed)) .def("auto_managed", _(&torrent_handle::auto_managed)) diff --git a/docs/manual.html b/docs/manual.html index 502298be8..95c0e9a57 100644 --- a/docs/manual.html +++ b/docs/manual.html @@ -97,130 +97,131 @@
+++void clear_error() const; ++
If the torrent is in an error state (i.e. torrent_status::error is non-empty), this +will clear the error and start the torrent again.
+diff --git a/docs/manual.rst b/docs/manual.rst index 1917380e3..cc07ab4f6 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -1567,6 +1567,7 @@ Its declaration looks like this:: bool is_paused() const; bool is_seed() const; void force_recheck() const; + void clear_error() const; void resolve_countries(bool r); bool resolve_countries() const; @@ -1841,6 +1842,15 @@ will be added to the checking queue, and will be checked (all the files will be compared to the piece hashes). Once the check is complete, the torrent will start connecting to peers again, as normal. +clear_error() +------------- + + :: + + void clear_error() const; + +If the torrent is in an error state (i.e. ``torrent_status::error`` is non-empty), this +will clear the error and start the torrent again. resolve_countries() ------------------- diff --git a/examples/client_test.cpp b/examples/client_test.cpp index d67e177d7..3e568c605 100644 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -1156,6 +1156,12 @@ int main(int ac, char* av[]) } } + if (c == 'c') + { + torrent_handle h = get_active_torrent(handles); + if (h.is_valid()) h.clear_error(); + } + // toggle displays if (c == 'i') print_peers = !print_peers; if (c == 'l') print_log = !print_log; @@ -1205,7 +1211,7 @@ int main(int ac, char* av[]) std::stringstream out; out << "[q] quit [i] toggle peers [d] toggle downloading pieces [p] toggle paused " "[a] toggle piece bar [s] toggle download sequential [f] toggle files " - "[j] force recheck [space] toggle session pause\n" + "[j] force recheck [space] toggle session pause [c] clear error\n" "[1] toggle IP [2] toggle AS [3] toggle timers [4] toggle block progress " "[5] toggle peer rate [6] toggle failures [7] toggle send buffers\n"; diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index eebd9ae74..2b6da1ac8 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -172,6 +172,8 @@ 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; } diff --git a/include/libtorrent/torrent_handle.hpp b/include/libtorrent/torrent_handle.hpp index 29e1e93f5..a062580c2 100644 --- a/include/libtorrent/torrent_handle.hpp +++ b/include/libtorrent/torrent_handle.hpp @@ -325,6 +325,8 @@ namespace libtorrent void file_progress(std::vector& progress) const TORRENT_DEPRECATED; void file_progress(std::vector & progress) const; + void clear_error() const; + std::vector const& trackers() const; void replace_trackers(std::vector const&) const; diff --git a/src/torrent.cpp b/src/torrent.cpp index a66fd69fb..e00ba1236 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -3604,6 +3604,14 @@ namespace libtorrent } } + void torrent::clear_error() + { + if (m_error.empty()) return; + if (m_ses.m_auto_manage_time_scaler > 2) + m_ses.m_auto_manage_time_scaler = 2; + m_error.clear(); + } + void torrent::auto_managed(bool a) { INVARIANT_CHECK; diff --git a/src/torrent_handle.cpp b/src/torrent_handle.cpp index 8e8542c77..4b8d8a452 100644 --- a/src/torrent_handle.cpp +++ b/src/torrent_handle.cpp @@ -319,6 +319,12 @@ namespace libtorrent TORRENT_FORWARD(set_queue_position((std::numeric_limits ::max)())); } + void torrent_handle::clear_error() const + { + INVARIANT_CHECK; + TORRENT_FORWARD(clear_error()); + } + void torrent_handle::set_tracker_login(std::string const& name , std::string const& password) const {