From cefc97597d2d0c9d46a9c5086ec85a8c20816952 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Fri, 4 Mar 2011 06:17:55 +0000 Subject: [PATCH] improve error reporting for save resume data for torrents with no metadata --- docs/manual.rst | 5 +++++ include/libtorrent/error_code.hpp | 2 +- src/error_code.cpp | 2 +- src/torrent.cpp | 7 +++++++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/docs/manual.rst b/docs/manual.rst index b276fcd1a..0526fb252 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -7439,6 +7439,11 @@ code symbol description ------ ----------------------------------------- ----------------------------------------------------------------- 108 too_frequent_pex The peer sent an pex messages too often. This is a possible attempt of and attack +------ ----------------------------------------- ----------------------------------------------------------------- +109 no_metadata The operation failed because it requires the torrent to have + the metadata (.torrent file) and it doesn't have it yet. + This happens for magnet links before they have downloaded the + metadata, and also torrents added by URL. ====== ========================================= ================================================================= NAT-PMP errors: diff --git a/include/libtorrent/error_code.hpp b/include/libtorrent/error_code.hpp index 42602dff5..88907ffa3 100644 --- a/include/libtorrent/error_code.hpp +++ b/include/libtorrent/error_code.hpp @@ -166,7 +166,7 @@ namespace libtorrent invalid_pex_message, invalid_lt_tracker_message, too_frequent_pex, - reserved109, + no_metadata, reserved110, reserved111, reserved112, diff --git a/src/error_code.cpp b/src/error_code.cpp index d7099bdce..113fcfdae 100644 --- a/src/error_code.cpp +++ b/src/error_code.cpp @@ -158,7 +158,7 @@ namespace libtorrent "invalid pex message", "invalid lt_tracker message", "pex messages sent too frequent (possible attack)", - "", + "torrent has no metadata", "", "", "", diff --git a/src/torrent.cpp b/src/torrent.cpp index a2ed4ba38..a837f7133 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -6007,6 +6007,13 @@ namespace libtorrent TORRENT_ASSERT(m_ses.is_network_thread()); INVARIANT_CHECK; + if (!valid_metadata()) + { + alerts().post_alert(save_resume_data_failed_alert(get_handle() + , errors::no_metadata)); + return; + } + if (!m_owning_storage.get()) { alerts().post_alert(save_resume_data_failed_alert(get_handle()