save resume data every 15 minutes no matter what

This commit is contained in:
Arvid Norberg 2010-08-25 06:38:04 +00:00
parent b44f71e217
commit fb8ebc53dd
2 changed files with 10 additions and 1 deletions

View File

@ -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

View File

@ -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