diff --git a/ChangeLog b/ChangeLog index 954b3d911..64d5f3ca4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -96,6 +96,7 @@ * improved fallocate support * fixed magnet link issue when using resume data * support disk I/O priority settings + * added info_hash to torrent_deleted_alert release 0.14.9 diff --git a/bindings/python/src/alert.cpp b/bindings/python/src/alert.cpp index b9e4907fb..12f391613 100644 --- a/bindings/python/src/alert.cpp +++ b/bindings/python/src/alert.cpp @@ -173,7 +173,9 @@ void bind_alert() class_, noncopyable>( "torrent_deleted_alert", no_init - ); + ) + .def_readonly("info_hash", &torrent_deleted_alert::info_hash) + ; class_, noncopyable>( "torrent_paused_alert", no_init diff --git a/docs/manual.rst b/docs/manual.rst index f25bcb165..8a0c60f7a 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -483,7 +483,8 @@ the tracker that we've stopped participating in the swarm. The optional second a ``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. +a libtorrent_exception_ exception. Once the torrent is deleted, a torrent_deleted_alert_ +is posted. find_torrent() get_torrents() ----------------------------- @@ -5547,6 +5548,27 @@ The ``error_code`` tells you why it failed. error_code error; }; +torrent_deleted_alert +--------------------- + +This alert is generated when a request to delete the files of a torrent complete. + +The ``info_hash`` is the info-hash of the torrent that was just deleted. Most of +the time the torrent_handle in the torrent_alert_ will be invalid by the time +this alert arrives, since the torrent is being deleted. The ``info_hash`` member +is hence the main way of identifying which torrent just completed the delete. + +This alert is posted in the ``storage_notification`` category, and that bit +needs to be set in the alert mask. + +:: + + struct torrent_deleted_alert: torrent_alert + { + // ... + sha1_hash info_hash; + }; + torrent_finished_alert ---------------------- diff --git a/include/libtorrent/alert_types.hpp b/include/libtorrent/alert_types.hpp index 3b2649282..e8cd75245 100644 --- a/include/libtorrent/alert_types.hpp +++ b/include/libtorrent/alert_types.hpp @@ -669,13 +669,15 @@ namespace libtorrent { torrent_deleted_alert(torrent_handle const& h) : torrent_alert(h) - {} + { info_hash = h.info_hash(); } TORRENT_DEFINE_ALERT(torrent_deleted_alert); const static int static_category = alert::storage_notification; virtual std::string message() const { return torrent_alert::message() + " deleted"; } + + sha1_hash info_hash; }; struct TORRENT_EXPORT torrent_delete_failed_alert: torrent_alert