added feature to ask a torrent if it needs to save its resume data or not
This commit is contained in:
parent
fb12950098
commit
b5efe1c92a
|
@ -1,3 +1,4 @@
|
||||||
|
* added feature to ask a torrent if it needs to save its resume data or not
|
||||||
* added setting to ignore file modification time when loading resume files
|
* added setting to ignore file modification time when loading resume files
|
||||||
* support more fine-grained torrent states between which peer sources it
|
* support more fine-grained torrent states between which peer sources it
|
||||||
announces to
|
announces to
|
||||||
|
|
|
@ -335,6 +335,7 @@ void bind_torrent_handle()
|
||||||
.def("file_priorities", &file_priorities)
|
.def("file_priorities", &file_priorities)
|
||||||
.def("use_interface", &torrent_handle::use_interface)
|
.def("use_interface", &torrent_handle::use_interface)
|
||||||
.def("save_resume_data", _(&torrent_handle::save_resume_data))
|
.def("save_resume_data", _(&torrent_handle::save_resume_data))
|
||||||
|
.def("need_save_resume_data", _(&torrent_handle::need_save_resume_data))
|
||||||
.def("force_reannounce", _(force_reannounce0))
|
.def("force_reannounce", _(force_reannounce0))
|
||||||
.def("force_reannounce", &force_reannounce)
|
.def("force_reannounce", &force_reannounce)
|
||||||
.def("force_dht_announce", _(&torrent_handle::force_dht_announce))
|
.def("force_dht_announce", _(&torrent_handle::force_dht_announce))
|
||||||
|
|
|
@ -1979,6 +1979,7 @@ Its declaration looks like this::
|
||||||
std::string name() const;
|
std::string name() const;
|
||||||
|
|
||||||
void save_resume_data() const;
|
void save_resume_data() const;
|
||||||
|
bool need_save_resume_data() const;
|
||||||
void force_reannounce() const;
|
void force_reannounce() const;
|
||||||
void force_dht_announce() const;
|
void force_dht_announce() const;
|
||||||
void force_reannounce(boost::posix_time::time_duration) const;
|
void force_reannounce(boost::posix_time::time_duration) const;
|
||||||
|
@ -2857,6 +2858,17 @@ Example code to pause and save resume data for all torrents and wait for the ale
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
need_save_resume_data()
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
|
bool need_save_resume_data() const;
|
||||||
|
|
||||||
|
This function returns true if any whole chunk has been downloaded since the
|
||||||
|
torrent was first loaded or since the last time the resume data was saved. When
|
||||||
|
saving resume data periodically, it makes sense to skip any torrent which hasn't
|
||||||
|
downloaded anything since the last time.
|
||||||
|
|
||||||
status()
|
status()
|
||||||
--------
|
--------
|
||||||
|
|
|
@ -266,6 +266,7 @@ namespace libtorrent
|
||||||
bool is_torrent_paused() const { return !m_allow_peers; }
|
bool is_torrent_paused() const { return !m_allow_peers; }
|
||||||
void force_recheck();
|
void force_recheck();
|
||||||
void save_resume_data();
|
void save_resume_data();
|
||||||
|
bool need_save_resume_data() const { return m_need_save_resume_data; }
|
||||||
|
|
||||||
bool is_auto_managed() const { return m_auto_managed; }
|
bool is_auto_managed() const { return m_auto_managed; }
|
||||||
void auto_managed(bool a);
|
void auto_managed(bool a);
|
||||||
|
@ -1070,8 +1071,10 @@ namespace libtorrent
|
||||||
#else
|
#else
|
||||||
unsigned int m_dummy_padding_bits_to_align:2;
|
unsigned int m_dummy_padding_bits_to_align:2;
|
||||||
#endif
|
#endif
|
||||||
// TODO: Add new bools here!
|
|
||||||
unsigned int m_dummy_padding_bit_to_alignt:1;
|
// set to false when saving resume data. Set to true
|
||||||
|
// whenever something is downloaded
|
||||||
|
bool m_need_save_resume_data:1;
|
||||||
|
|
||||||
// total time we've been available as a seed on this torrent
|
// total time we've been available as a seed on this torrent
|
||||||
// does not count when the torrent is stopped or paused
|
// does not count when the torrent is stopped or paused
|
||||||
|
|
|
@ -466,6 +466,7 @@ namespace libtorrent
|
||||||
|
|
||||||
void force_recheck() const;
|
void force_recheck() const;
|
||||||
void save_resume_data() const;
|
void save_resume_data() const;
|
||||||
|
bool need_save_resume_data() const;
|
||||||
|
|
||||||
bool is_auto_managed() const;
|
bool is_auto_managed() const;
|
||||||
void auto_managed(bool m) const;
|
void auto_managed(bool m) const;
|
||||||
|
|
|
@ -354,6 +354,7 @@ namespace libtorrent
|
||||||
, m_resolving_country(false)
|
, m_resolving_country(false)
|
||||||
, m_resolve_countries(false)
|
, m_resolve_countries(false)
|
||||||
#endif
|
#endif
|
||||||
|
, m_need_save_resume_data(false)
|
||||||
, m_seeding_time(0)
|
, m_seeding_time(0)
|
||||||
, m_time_scaler(0)
|
, m_time_scaler(0)
|
||||||
, m_max_uploads(~0)
|
, m_max_uploads(~0)
|
||||||
|
@ -713,7 +714,7 @@ namespace libtorrent
|
||||||
mutex::scoped_lock l(m_ses.m_mutex);
|
mutex::scoped_lock l(m_ses.m_mutex);
|
||||||
|
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
if (is_seed()) return;
|
if (is_seed()) return;
|
||||||
|
|
||||||
if (m_abort)
|
if (m_abort)
|
||||||
|
@ -735,6 +736,8 @@ namespace libtorrent
|
||||||
// add_piece() multiple times
|
// add_piece() multiple times
|
||||||
if (picker().is_finished(block_finished)) return;
|
if (picker().is_finished(block_finished)) return;
|
||||||
|
|
||||||
|
m_need_save_resume_data = true;
|
||||||
|
|
||||||
picker().mark_as_finished(block_finished, 0);
|
picker().mark_as_finished(block_finished, 0);
|
||||||
|
|
||||||
// did we just finish the piece?
|
// did we just finish the piece?
|
||||||
|
@ -2557,6 +2560,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
m_need_save_resume_data = false;
|
||||||
write_resume_data(*j.resume_data);
|
write_resume_data(*j.resume_data);
|
||||||
alerts().post_alert(save_resume_data_alert(j.resume_data
|
alerts().post_alert(save_resume_data_alert(j.resume_data
|
||||||
, get_handle()));
|
, get_handle()));
|
||||||
|
@ -5227,6 +5231,8 @@ namespace libtorrent
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_need_save_resume_data = false;
|
||||||
|
|
||||||
TORRENT_ASSERT(m_storage);
|
TORRENT_ASSERT(m_storage);
|
||||||
if (m_state == torrent_status::queued_for_checking
|
if (m_state == torrent_status::queued_for_checking
|
||||||
|| m_state == torrent_status::checking_files
|
|| m_state == torrent_status::checking_files
|
||||||
|
|
|
@ -304,6 +304,12 @@ namespace libtorrent
|
||||||
TORRENT_FORWARD(save_resume_data());
|
TORRENT_FORWARD(save_resume_data());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool torrent_handle::need_save_resume_data() const
|
||||||
|
{
|
||||||
|
INVARIANT_CHECK;
|
||||||
|
TORRENT_FORWARD_RETURN(need_save_resume_data(), false);
|
||||||
|
}
|
||||||
|
|
||||||
void torrent_handle::force_recheck() const
|
void torrent_handle::force_recheck() const
|
||||||
{
|
{
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
Loading…
Reference in New Issue