diff --git a/include/libtorrent/add_torrent_params.hpp b/include/libtorrent/add_torrent_params.hpp index cef3793a4..81cfec38a 100644 --- a/include/libtorrent/add_torrent_params.hpp +++ b/include/libtorrent/add_torrent_params.hpp @@ -271,9 +271,16 @@ namespace libtorrent // list of web seeds used by the torrent. flag_override_web_seeds = 0x10000, + // if this flag is set (which it is by default) the torrent will be + // considered needing to save its resume data immediately as it's + // added. New torrents that don't have any resume data should do that. + // This flag is cleared by a successful call to read_resume_data() + flag_need_save_resume = 0x20000, + // internal default_flags = flag_pinned | flag_update_subscribe | flag_auto_managed | flag_paused | flag_apply_ip_filter + | flag_need_save_resume #ifndef TORRENT_NO_DEPRECATE | flag_merge_resume_http_seeds | flag_merge_resume_trackers diff --git a/src/read_resume_data.cpp b/src/read_resume_data.cpp index ac12a3bb9..5d9fce912 100644 --- a/src/read_resume_data.cpp +++ b/src/read_resume_data.cpp @@ -327,6 +327,8 @@ namespace libtorrent } } + ret.flags &= ~add_torrent_params::flag_need_save_resume; + return ret; } diff --git a/src/torrent.cpp b/src/torrent.cpp index 1f21f7bbe..f15c691a4 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -244,7 +244,7 @@ namespace libtorrent , m_resolve_countries(false) #endif #endif - , m_need_save_resume_data(true) + , m_need_save_resume_data(p.flags & add_torrent_params::flag_need_save_resume) , m_seeding_time(0) , m_max_uploads((1<<24)-1) , m_save_resume_flags(0) @@ -290,12 +290,6 @@ namespace libtorrent inc_stats_counter(counters::num_loaded_torrents); - // if there is resume data already, we don't need to trigger the initial save - // resume data -//TODO: 4 maybe m_need_save_resume_data should be another flag in add_torrent_params - if (!p.have_pieces.empty() /* && (p.flags & add_torrent_params::flag_override_resume_data) == 0 */ ) - m_need_save_resume_data = false; - #if TORRENT_USE_UNC_PATHS m_save_path = canonicalize_path(m_save_path); #endif