diff --git a/ChangeLog b/ChangeLog index 0be6b8224..ed0f00e2c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -71,6 +71,7 @@ * added support for bitcomet padding files * improved support for sparse files on windows * added ability to give seeding torrents preference to active slots + * added torrent_status::finished_time release 0.14.7 diff --git a/bindings/python/src/torrent_status.cpp b/bindings/python/src/torrent_status.cpp index 1f83af9be..92d2fbb64 100644 --- a/bindings/python/src/torrent_status.cpp +++ b/bindings/python/src/torrent_status.cpp @@ -74,6 +74,7 @@ void bind_torrent_status() .def_readonly("all_time_upload", &torrent_status::all_time_upload) .def_readonly("all_time_download", &torrent_status::all_time_download) .def_readonly("active_time", &torrent_status::active_time) + .def_readonly("finished_time", &torrent_status::finished_time) .def_readonly("seeding_time", &torrent_status::seeding_time) .def_readonly("seed_rank", &torrent_status::seed_rank) .def_readonly("last_scrape", &torrent_status::last_scrape) diff --git a/docs/manual.rst b/docs/manual.rst index a12f0eb22..cd26d6c3b 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -2885,6 +2885,7 @@ It contains the following fields:: size_type all_time_download; int active_time; + int finished_time; int seeding_time; int seed_rank; @@ -3089,11 +3090,12 @@ the ``session_status`` object. payload byte counters. They are saved in and restored from resume data to keep totals across sessions. -``active_time`` and ``seeding_time`` are second counters. They keep track of the -number of seconds this torrent has been active (not paused) and the number of -seconds it has been active while being a seed. ``seeding_time`` should be >= -``active_time`` They are saved in and restored from resume data, to keep totals -across sessions. +``active_time``, ``finished_time`` and ``seeding_time`` are second counters. +They keep track of the number of seconds this torrent has been active (not +paused) and the number of seconds it has been active while being finished and +active while being a seed. ``seeding_time`` should be >= ``finished_time`` which +should be >= ``active_time``. They are all saved in and restored from resume data, +to keep totals across sessions. ``seed_rank`` is a rank of how important it is to seed the torrent, it is used to determine which torrents to seed and which to queue. It is based on the peer diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index c919b9930..fa270bb06 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -736,6 +736,10 @@ namespace libtorrent // does not count when the torrent is stopped or paused time_duration m_active_time; + // total time we've been finished with this torrent + // does not count when the torrent is stopped or paused + time_duration m_finished_time; + // total time we've been available as a seed on this torrent // does not count when the torrent is stopped or paused time_duration m_seeding_time; diff --git a/include/libtorrent/torrent_handle.hpp b/include/libtorrent/torrent_handle.hpp index 33a0e17f6..8441a6876 100644 --- a/include/libtorrent/torrent_handle.hpp +++ b/include/libtorrent/torrent_handle.hpp @@ -112,6 +112,7 @@ namespace libtorrent , all_time_upload(0) , all_time_download(0) , active_time(0) + , finished_time(0) , seeding_time(0) , seed_rank(0) , last_scrape(0) @@ -272,6 +273,7 @@ namespace libtorrent // and as being a seed, saved and restored // from resume data int active_time; + int finished_time; int seeding_time; // higher value means more important to seed diff --git a/src/torrent.cpp b/src/torrent.cpp index 8ee0e3330..bd582b8d3 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -205,6 +205,7 @@ namespace libtorrent , add_torrent_params const& p) : m_policy(this) , m_active_time(seconds(0)) + , m_finished_time(seconds(0)) , m_seeding_time(seconds(0)) , m_total_uploaded(0) , m_total_downloaded(0) @@ -3382,6 +3383,7 @@ namespace libtorrent m_total_uploaded = rd.dict_find_int_value("total_uploaded"); m_total_downloaded = rd.dict_find_int_value("total_downloaded"); m_active_time = seconds(rd.dict_find_int_value("active_time")); + m_finished_time = seconds(rd.dict_find_int_value("finished_time")); m_seeding_time = seconds(rd.dict_find_int_value("seeding_time")); m_complete = rd.dict_find_int_value("num_seeds", -1); m_incomplete = rd.dict_find_int_value("num_downloaders", -1); @@ -3521,6 +3523,7 @@ namespace libtorrent ret["total_downloaded"] = m_total_downloaded; ret["active_time"] = total_seconds(m_active_time); + ret["finished_time"] = total_seconds(m_finished_time); ret["seeding_time"] = total_seconds(m_seeding_time); int seeds = 0; @@ -4885,15 +4888,15 @@ namespace libtorrent ptime now = time_now(); - int seed_time = total_seconds(m_seeding_time); - int download_time = total_seconds(m_active_time) - seed_time; + int finished_time = total_seconds(m_finished_time); + int download_time = total_seconds(m_active_time) - finished_time; // if we haven't yet met the seed limits, set the seed_ratio_not_met // flag. That will make this seed prioritized // downloaded may be 0 if the torrent is 0-sized size_type downloaded = (std::max)(m_total_downloaded, m_torrent_file->total_size()); - if (seed_time < s.seed_time_limit - && (download_time > 1 && seed_time / download_time < s.seed_time_ratio_limit) + if (finished_time < s.seed_time_limit + && (download_time > 1 && finished_time / download_time < s.seed_time_ratio_limit) && downloaded > 0 && m_total_uploaded / downloaded < s.share_ratio_limit) ret |= seed_ratio_not_met; @@ -5769,6 +5772,7 @@ namespace libtorrent st.all_time_upload = m_total_uploaded; st.all_time_download = m_total_downloaded; + st.active_time = total_seconds(m_active_time); st.active_time = total_seconds(m_active_time); st.seeding_time = total_seconds(m_seeding_time);