fix resume state for paused when torrent was in graceful pause mode
This commit is contained in:
parent
f60e88e7f8
commit
b8614a36b3
|
@ -862,6 +862,14 @@ void handle_alert(libtorrent::session& ses, libtorrent::alert* a
|
|||
, boost::bind(&handles_t::value_type::second, _1) == h) == files.end())
|
||||
ses.remove_torrent(h);
|
||||
}
|
||||
else if (torrent_paused_alert* p = alert_cast<torrent_paused_alert>(a))
|
||||
{
|
||||
// write resume data for the finished torrent
|
||||
// the alert handler for save_resume_data_alert
|
||||
// will save it to disk
|
||||
torrent_handle h = p->handle;
|
||||
h.save_resume_data();
|
||||
}
|
||||
}
|
||||
|
||||
static char const* state_str[] =
|
||||
|
@ -1486,9 +1494,6 @@ int main(int argc, char* argv[])
|
|||
ts.handle.auto_managed(false);
|
||||
ts.handle.pause(torrent_handle::graceful_pause);
|
||||
}
|
||||
// the alert handler for save_resume_data_alert
|
||||
// will save it to disk
|
||||
if (ts.need_save_resume) ts.handle.save_resume_data();
|
||||
}
|
||||
|
||||
if (c == 'c' && !handles.empty())
|
||||
|
|
|
@ -1318,6 +1318,12 @@ namespace libtorrent
|
|||
// if set to true, add tracker URLs loaded from resume
|
||||
// data into this torrent instead of replacing them
|
||||
bool m_merge_resume_trackers:1;
|
||||
|
||||
#ifdef TORRENT_DEBUG
|
||||
public:
|
||||
// set to false until we've loaded resume data
|
||||
bool m_resume_data_loaded;
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -3507,6 +3507,7 @@ namespace aux {
|
|||
if (t->state() == torrent_status::checking_files
|
||||
|| t->state() == torrent_status::queued_for_checking)
|
||||
continue;
|
||||
TORRENT_ASSERT(t->m_resume_data_loaded);
|
||||
if (t->is_auto_managed() && !t->has_error())
|
||||
{
|
||||
// this torrent is auto managed, add it to
|
||||
|
|
|
@ -409,6 +409,9 @@ namespace libtorrent
|
|||
, m_apply_ip_filter(p.apply_ip_filter)
|
||||
, m_merge_resume_trackers(p.merge_resume_trackers)
|
||||
{
|
||||
#ifdef TORRENT_DEBUG
|
||||
m_resume_data_loaded = false;
|
||||
#endif
|
||||
if (!m_apply_ip_filter) ++m_ses.m_non_filtered_torrents;
|
||||
|
||||
if (!p.ti || !p.ti->is_valid())
|
||||
|
@ -1352,6 +1355,10 @@ namespace libtorrent
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef TORRENT_DEBUG
|
||||
m_resume_data_loaded = true;
|
||||
#endif
|
||||
|
||||
TORRENT_ASSERT(block_size() > 0);
|
||||
int file = 0;
|
||||
for (file_storage::iterator i = m_torrent_file->files().begin()
|
||||
|
@ -3415,6 +3422,9 @@ namespace libtorrent
|
|||
}
|
||||
if (filter_updated)
|
||||
{
|
||||
// we need to save this new state
|
||||
m_need_save_resume_data = true;
|
||||
|
||||
update_peer_interest(was_finished);
|
||||
remove_time_critical_pieces(pieces);
|
||||
}
|
||||
|
@ -4789,7 +4799,7 @@ namespace libtorrent
|
|||
ret["download_rate_limit"] = download_limit();
|
||||
ret["max_connections"] = max_connections();
|
||||
ret["max_uploads"] = max_uploads();
|
||||
ret["paused"] = !m_allow_peers;
|
||||
ret["paused"] = is_torrent_paused();
|
||||
ret["announce_to_dht"] = m_announce_to_dht;
|
||||
ret["announce_to_trackers"] = m_announce_to_trackers;
|
||||
ret["announce_to_lsd"] = m_announce_to_lsd;
|
||||
|
@ -6055,6 +6065,10 @@ namespace libtorrent
|
|||
if (m_auto_managed == a) return;
|
||||
bool checking_files = should_check_files();
|
||||
m_auto_managed = a;
|
||||
|
||||
// we need to save this new state as well
|
||||
m_need_save_resume_data = true;
|
||||
|
||||
// recalculate which torrents should be
|
||||
// paused
|
||||
m_ses.m_auto_manage_time_scaler = 0;
|
||||
|
@ -6232,6 +6246,9 @@ namespace libtorrent
|
|||
m_announce_to_trackers = false;
|
||||
m_announce_to_lsd = false;
|
||||
|
||||
// we need to save this new state
|
||||
m_need_save_resume_data = true;
|
||||
|
||||
bool prev_graceful = m_graceful_pause_mode;
|
||||
m_graceful_pause_mode = graceful;
|
||||
|
||||
|
@ -6382,6 +6399,10 @@ namespace libtorrent
|
|||
m_announce_to_trackers = true;
|
||||
m_announce_to_lsd = true;
|
||||
if (!m_ses.is_paused()) m_graceful_pause_mode = false;
|
||||
|
||||
// we need to save this new state
|
||||
m_need_save_resume_data = true;
|
||||
|
||||
do_resume();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue