diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index ab259d900..8c7eefab9 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -267,7 +267,12 @@ namespace libtorrent bool is_torrent_paused() const { return !m_allow_peers; } void force_recheck(); void save_resume_data(); - bool need_save_resume_data() const { return m_need_save_resume_data; } + bool need_save_resume_data() const + { + // save resume data every 15 minutes regardless, just to + // keep stats up to date + return m_need_save_resume_data || time(0) - m_last_saved_resume > 15 * 60; + } bool is_auto_managed() const { return m_auto_managed; } void auto_managed(bool a); @@ -1009,6 +1014,7 @@ namespace libtorrent time_t m_added_time; time_t m_completed_time; time_t m_last_seen_complete; + time_t m_last_saved_resume; // ============================== // The following members are specifically diff --git a/src/torrent.cpp b/src/torrent.cpp index 3a5844692..5522f2a69 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -335,6 +335,7 @@ namespace libtorrent , m_added_time(time(0)) , m_completed_time(0) , m_last_seen_complete(0) + , m_last_saved_resume(time(0)) , m_upload_mode_time(0) , m_state(torrent_status::checking_resume_data) , m_storage_mode(p.storage_mode) @@ -2633,6 +2634,7 @@ namespace libtorrent else { m_need_save_resume_data = false; + m_last_saved_resume = time(0); write_resume_data(*j.resume_data); alerts().post_alert(save_resume_data_alert(j.resume_data , get_handle())); @@ -5374,6 +5376,7 @@ namespace libtorrent } m_need_save_resume_data = false; + m_last_saved_resume = time(0); TORRENT_ASSERT(m_storage); if (m_state == torrent_status::queued_for_checking