diff --git a/include/libtorrent/alert_types.hpp b/include/libtorrent/alert_types.hpp index 0915ff662..1ef1d31dc 100644 --- a/include/libtorrent/alert_types.hpp +++ b/include/libtorrent/alert_types.hpp @@ -961,12 +961,14 @@ namespace libtorrent }; // This alert is generated when a request to delete the files of a torrent fails. + // Just removing a torrent from the session cannot fail struct TORRENT_EXPORT torrent_delete_failed_alert: torrent_alert { // internal - torrent_delete_failed_alert(torrent_handle const& h, error_code const& e) + torrent_delete_failed_alert(torrent_handle const& h, error_code const& e, sha1_hash const& ih) : torrent_alert(h) , error(e) + , info_hash(ih) { #ifndef TORRENT_NO_DEPRECATE msg = convert_from_native(error.message()); @@ -987,6 +989,9 @@ namespace libtorrent // tells you why it failed. error_code error; + // the info hash of the torrent whose files failed to be deleted + sha1_hash info_hash; + #ifndef TORRENT_NO_DEPRECATE std::string msg; #endif diff --git a/include/libtorrent/session.hpp b/include/libtorrent/session.hpp index e5391d546..5b616d500 100644 --- a/include/libtorrent/session.hpp +++ b/include/libtorrent/session.hpp @@ -668,12 +668,14 @@ namespace libtorrent }; // ``remove_torrent()`` will close all peer connections associated with the torrent and tell - // the tracker that we've stopped participating in the swarm. The optional second argument - // `options`` can be used to delete all the files downloaded by this torrent. To do this, pass - // in the value ``session::delete_files``. The removal of the torrent is asyncronous, there is - // no guarantee that adding the same torrent immediately after it was removed will not throw - // a libtorrent_exception exception. Once the torrent is deleted, a torrent_deleted_alert - // is posted. + // the tracker that we've stopped participating in the swarm. This operation cannot fail. + // When it completes, you will receive a torrent_removed_alert. + // + // The optional second argument ``options`` can be used to delete all the files downloaded + // by this torrent. To do so, pass in the value ``session::delete_files``. The removal + // of the torrent is asyncronous, there is no guarantee that adding the same torrent + // immediately after it was removed will not throw a libtorrent_exception exception. Once + // the torrent is deleted, a torrent_deleted_alert is posted. void remove_torrent(const torrent_handle& h, int options = 0); // Sets the session settings and the packet encryption settings respectively. diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 9152bf109..9807f5a4b 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -5530,7 +5530,8 @@ retry: if (!t.delete_files()) { if (m_alerts.should_post()) - m_alerts.post_alert(torrent_delete_failed_alert(t.get_handle(), error_code())); + m_alerts.post_alert(torrent_delete_failed_alert(t.get_handle() + , error_code(), t.torrent_file().info_hash())); } } diff --git a/src/torrent.cpp b/src/torrent.cpp index 7d8ce4781..30913aabe 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -3709,7 +3709,7 @@ namespace libtorrent if (ret != 0) { - alerts().post_alert(torrent_delete_failed_alert(get_handle(), j.error)); + alerts().post_alert(torrent_delete_failed_alert(get_handle(), j.error, m_torrent_file->info_hash())); } else {