forked from premiere/premiere-libtorrent
won't save resume data for torrents without a complete state (checking or queued for checking torrents)
This commit is contained in:
parent
84221e05f8
commit
ca0f17ee95
|
@ -1054,11 +1054,14 @@ int main(int ac, char* av[])
|
||||||
|
|
||||||
std::auto_ptr<alert> holder = ses.pop_alert();
|
std::auto_ptr<alert> holder = ses.pop_alert();
|
||||||
save_resume_data_alert const* rd = dynamic_cast<save_resume_data_alert const*>(a);
|
save_resume_data_alert const* rd = dynamic_cast<save_resume_data_alert const*>(a);
|
||||||
if (rd == 0)
|
if (!rd)
|
||||||
{
|
{
|
||||||
std::cout << a->msg() << std::endl;
|
std::cout << a->msg() << std::endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
--num_resume_data;
|
||||||
|
|
||||||
|
if (!rd->resume_data) continue;
|
||||||
|
|
||||||
torrent_handle h = rd->handle;
|
torrent_handle h = rd->handle;
|
||||||
boost::filesystem::ofstream out(h.save_path()
|
boost::filesystem::ofstream out(h.save_path()
|
||||||
|
@ -1066,7 +1069,6 @@ int main(int ac, char* av[])
|
||||||
out.unsetf(std::ios_base::skipws);
|
out.unsetf(std::ios_base::skipws);
|
||||||
bencode(std::ostream_iterator<char>(out), *rd->resume_data);
|
bencode(std::ostream_iterator<char>(out), *rd->resume_data);
|
||||||
std::cout << "fast resume data saved for " << h.name() << std::endl;
|
std::cout << "fast resume data saved for " << h.name() << std::endl;
|
||||||
--num_resume_data;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3686,8 +3686,20 @@ namespace libtorrent
|
||||||
if (m_owning_storage.get())
|
if (m_owning_storage.get())
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(m_storage);
|
TORRENT_ASSERT(m_storage);
|
||||||
m_storage->async_save_resume_data(
|
if (m_state == torrent_status::queued_for_checking
|
||||||
bind(&torrent::on_save_resume_data, shared_from_this(), _1, _2));
|
|| m_state == torrent_status::checking_files)
|
||||||
|
{
|
||||||
|
if (alerts().should_post(alert::warning))
|
||||||
|
{
|
||||||
|
alerts().post_alert(save_resume_data_alert(boost::shared_ptr<entry>()
|
||||||
|
, get_handle(), "won't save resume data, torrent does not have a complete resume state yet"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_storage->async_save_resume_data(
|
||||||
|
bind(&torrent::on_save_resume_data, shared_from_this(), _1, _2));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue