introduced an error state for torrents. Torrents with an error are not restarted automatically

This commit is contained in:
Arvid Norberg 2008-05-20 07:57:44 +00:00
parent aed8f355b0
commit 67354421fb
7 changed files with 33 additions and 4 deletions

View File

@ -2206,6 +2206,8 @@ struct torrent_status
state_t state; state_t state;
bool paused; bool paused;
float progress; float progress;
std::string error;
boost::posix_time::time_duration next_announce; boost::posix_time::time_duration next_announce;
boost::posix_time::time_duration announce_interval; boost::posix_time::time_duration announce_interval;
@ -2319,6 +2321,9 @@ allocated.</td>
</table> </table>
<p>When downloading, the progress is <tt class="docutils literal"><span class="pre">total_wanted_done</span></tt> / <tt class="docutils literal"><span class="pre">total_wanted</span></tt>.</p> <p>When downloading, the progress is <tt class="docutils literal"><span class="pre">total_wanted_done</span></tt> / <tt class="docutils literal"><span class="pre">total_wanted</span></tt>.</p>
<p><tt class="docutils literal"><span class="pre">paused</span></tt> is set to true if the torrent is paused and false otherwise.</p> <p><tt class="docutils literal"><span class="pre">paused</span></tt> is set to true if the torrent is paused and false otherwise.</p>
<p><tt class="docutils literal"><span class="pre">error</span></tt> may be set to an error message describing why the torrent was paused, in
case it was paused by an error. If the torrent is not paused or if it's paused but
not because of an error, this string is empty.</p>
<p><tt class="docutils literal"><span class="pre">next_announce</span></tt> is the time until the torrent will announce itself to the tracker. And <p><tt class="docutils literal"><span class="pre">next_announce</span></tt> is the time until the torrent will announce itself to the tracker. And
<tt class="docutils literal"><span class="pre">announce_interval</span></tt> is the time the tracker want us to wait until we announce ourself <tt class="docutils literal"><span class="pre">announce_interval</span></tt> is the time the tracker want us to wait until we announce ourself
again the next time.</p> again the next time.</p>

View File

@ -2170,6 +2170,8 @@ It contains the following fields::
state_t state; state_t state;
bool paused; bool paused;
float progress; float progress;
std::string error;
boost::posix_time::time_duration next_announce; boost::posix_time::time_duration next_announce;
boost::posix_time::time_duration announce_interval; boost::posix_time::time_duration announce_interval;
@ -2273,6 +2275,10 @@ When downloading, the progress is ``total_wanted_done`` / ``total_wanted``.
``paused`` is set to true if the torrent is paused and false otherwise. ``paused`` is set to true if the torrent is paused and false otherwise.
``error`` may be set to an error message describing why the torrent was paused, in
case it was paused by an error. If the torrent is not paused or if it's paused but
not because of an error, this string is empty.
``next_announce`` is the time until the torrent will announce itself to the tracker. And ``next_announce`` is the time until the torrent will announce itself to the tracker. And
``announce_interval`` is the time the tracker want us to wait until we announce ourself ``announce_interval`` is the time the tracker want us to wait until we announce ourself
again the next time. again the next time.

View File

@ -1253,6 +1253,13 @@ int main(int ac, char* av[])
bool paused = h.is_paused(); bool paused = h.is_paused();
bool auto_managed = h.is_auto_managed(); bool auto_managed = h.is_auto_managed();
out << std::setw(13) << std::setiosflags(std::ios::left); out << std::setw(13) << std::setiosflags(std::ios::left);
if (!s.error.empty())
{
out << esc("31") << "error " << s.error;
out << esc("0") << std::endl;
continue;
}
if (paused && !auto_managed) out << "paused"; if (paused && !auto_managed) out << "paused";
else if (paused && auto_managed) out << "queued"; else if (paused && auto_managed) out << "queued";
else else

View File

@ -181,6 +181,7 @@ namespace libtorrent
void ip_filter_updated() { m_policy.ip_filter_updated(); } void ip_filter_updated() { m_policy.ip_filter_updated(); }
bool has_error() const { return !m_error.empty(); }
void pause(); void pause();
void resume(); void resume();
bool is_paused() const { return m_paused; } bool is_paused() const { return m_paused; }
@ -750,6 +751,10 @@ namespace libtorrent
// the state of this torrent (queued, checking, downloading) // the state of this torrent (queued, checking, downloading)
torrent_status::state_t m_state; torrent_status::state_t m_state;
// if there's an error on this torrent, this is the
// error message
std::string m_error;
entry m_resume_data; entry m_resume_data;
// if the torrent is started without metadata, it may // if the torrent is started without metadata, it may

View File

@ -137,6 +137,8 @@ namespace libtorrent
state_t state; state_t state;
bool paused; bool paused;
float progress; float progress;
std::string error;
boost::posix_time::time_duration next_announce; boost::posix_time::time_duration next_announce;
boost::posix_time::time_duration announce_interval; boost::posix_time::time_duration announce_interval;

View File

@ -1043,7 +1043,7 @@ namespace aux {
else else
++uncongested_torrents; ++uncongested_torrents;
if (t.is_auto_managed() && t.is_paused()) if (t.is_auto_managed() && t.is_paused() && !t.has_error())
{ {
++num_paused_auto_managed; ++num_paused_auto_managed;
if (!least_recently_scraped->second->is_auto_managed() if (!least_recently_scraped->second->is_auto_managed()
@ -1308,7 +1308,7 @@ namespace aux {
{ {
torrent* t = i->second.get(); torrent* t = i->second.get();
TORRENT_ASSERT(t); TORRENT_ASSERT(t);
if (t->is_auto_managed()) if (t->is_auto_managed() && !t->has_error())
{ {
// this torrent is auto managed, add it to // this torrent is auto managed, add it to
// the list (depending on if it's a seed or not) // the list (depending on if it's a seed or not)

View File

@ -449,7 +449,7 @@ namespace libtorrent
} }
std::fill(m_have_pieces.begin(), m_have_pieces.end(), false); std::fill(m_have_pieces.begin(), m_have_pieces.end(), false);
m_num_pieces = 0; m_num_pieces = 0;
auto_managed(false); m_error = j.str;
pause(); pause();
return; return;
} }
@ -637,7 +637,7 @@ namespace libtorrent
} }
std::fill(m_have_pieces.begin(), m_have_pieces.end(), false); std::fill(m_have_pieces.begin(), m_have_pieces.end(), false);
m_num_pieces = 0; m_num_pieces = 0;
auto_managed(false); m_error = j.str;
pause(); pause();
m_ses.done_checking(shared_from_this()); m_ses.done_checking(shared_from_this());
return; return;
@ -3564,6 +3564,7 @@ namespace libtorrent
m_paused = false; m_paused = false;
m_started = time_now(); m_started = time_now();
m_error.clear();
// tell the tracker that we're back // tell the tracker that we're back
m_event = tracker_request::started; m_event = tracker_request::started;
@ -3750,6 +3751,7 @@ namespace libtorrent
{ {
alerts().post_alert(file_error_alert(j.error_file, get_handle(), j.str)); alerts().post_alert(file_error_alert(j.error_file, get_handle(), j.str));
} }
m_error = j.str;
pause(); pause();
} }
f(ret); f(ret);
@ -3809,6 +3811,8 @@ namespace libtorrent
torrent_status st; torrent_status st;
st.error = m_error;
if (m_last_scrape == min_time()) if (m_last_scrape == min_time())
{ {
st.last_scrape = -1; st.last_scrape = -1;