From 9baa134343cab2587f9c130e63daee49f461ecb4 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Thu, 14 Jul 2011 03:45:24 +0000 Subject: [PATCH] handle invalid handles when removing torrents --- examples/client_test.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/client_test.cpp b/examples/client_test.cpp index 857dd5f11..e5fda80b3 100644 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -869,7 +869,8 @@ void handle_alert(libtorrent::session& ses, libtorrent::alert* a std::vector out; bencode(std::back_inserter(out), *p->resume_data); save_file(combine_path(h.save_path(), ".resume/" + to_hex(h.info_hash().to_string()) + ".resume"), out); - if (non_files.find(h) == non_files.end() + if (h.is_valid() + && non_files.find(h) == non_files.end() && std::find_if(files.begin(), files.end() , boost::bind(&handles_t::value_type::second, _1) == h) == files.end()) ses.remove_torrent(h); @@ -879,7 +880,8 @@ void handle_alert(libtorrent::session& ses, libtorrent::alert* a { --num_outstanding_resume_data; torrent_handle h = p->handle; - if (non_files.find(h) == non_files.end() + if (h.is_valid() + && non_files.find(h) == non_files.end() && std::find_if(files.begin(), files.end() , boost::bind(&handles_t::value_type::second, _1) == h) == files.end()) ses.remove_torrent(h); @@ -1532,7 +1534,8 @@ int main(int argc, char* argv[]) remove(combine_path(monitor_dir, i->first), ec); if (ec) printf("failed to delete .torrent file: %s\n", ec.message().c_str()); } - ses.remove_torrent(h, session::delete_files); + if (h.is_valid()) + ses.remove_torrent(h, session::delete_files); } } }