diff --git a/docs/manual.rst b/docs/manual.rst index 4942e10f8..311b069ee 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -3368,6 +3368,8 @@ It contains the following fields:: int queue_position; bool need_save_resume; bool ip_filter_applies; + + sha1_hash info_hash; }; ``handle`` is a handle to the torrent whose status the object represents. @@ -3641,6 +3643,8 @@ was saved. ``ip_filter_applies`` is true if the session global IP filter applies to this torrent. This defaults to true. +``info_hash`` is the info-hash of the torrent. + peer_info ========= @@ -7046,6 +7050,8 @@ cache_flushed_alert This alert is posted when the disk cache has been flushed for a specific torrent as a result of a call to `flush_cache()`_. This alert belongs to the ``storage_notification`` category, which must be enabled to let this alert through. +The alert is also posted when removing a torrent from the session, once the outstanding +cache flush is complete and the torrent does no longer have any files open. :: diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index 94d755571..e5b7b5686 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -833,7 +833,6 @@ namespace libtorrent void on_files_deleted(int ret, disk_io_job const& j); void on_files_released(int ret, disk_io_job const& j); - void on_torrent_aborted(int ret, disk_io_job const& j); void on_torrent_paused(int ret, disk_io_job const& j); void on_storage_moved(int ret, disk_io_job const& j); void on_save_resume_data(int ret, disk_io_job const& j); diff --git a/include/libtorrent/torrent_handle.hpp b/include/libtorrent/torrent_handle.hpp index 6288c4471..4c9a087fc 100644 --- a/include/libtorrent/torrent_handle.hpp +++ b/include/libtorrent/torrent_handle.hpp @@ -478,6 +478,7 @@ namespace libtorrent , queue_position(0) , need_save_resume(false) , ip_filter_applies(true) + , info_hash(0) {} // handle to the torrent @@ -690,6 +691,9 @@ namespace libtorrent // defaults to true. Determines whether the session // IP filter applies to this torrent or not bool ip_filter_applies; + + // the info-hash for this torrent + sha1_hash info_hash; }; } diff --git a/src/torrent.cpp b/src/torrent.cpp index a8d4566a9..40e180a2d 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -3079,7 +3079,7 @@ namespace libtorrent { m_storage->abort_disk_io(); m_storage->async_release_files( - boost::bind(&torrent::on_torrent_aborted, shared_from_this(), _1, _2)); + boost::bind(&torrent::on_cache_flushed, shared_from_this(), _1, _2)); } dequeue_torrent_check(); @@ -3187,12 +3187,6 @@ namespace libtorrent */ } - void torrent::on_torrent_aborted(int ret, disk_io_job const& j) - { - // the torrent should be completely shut down now, and the - // destructor has to be called from the main thread - } - void torrent::on_save_resume_data(int ret, disk_io_job const& j) { TORRENT_ASSERT(m_ses.is_network_thread()); @@ -6140,6 +6134,9 @@ namespace libtorrent void torrent::on_cache_flushed(int ret, disk_io_job const& j) { TORRENT_ASSERT(m_ses.is_network_thread()); + + if (m_ses.is_aborted()) return; + if (alerts().should_post()) alerts().post_alert(cache_flushed_alert(get_handle())); } @@ -7320,6 +7317,7 @@ namespace libtorrent ptime now = time_now(); st->handle = get_handle(); + st->info_hash = info_hash(); st->has_incoming = m_has_incoming; if (m_error) st->error = m_error.message() + ": " + m_error_file;