post fastresume_reject_alerts when building with deprecated functions enabled
This commit is contained in:
parent
b23cb76b6f
commit
a5d131b1bb
|
@ -492,6 +492,12 @@ namespace libtorrent
|
|||
// will be swapped into the running torrent instance with
|
||||
// ``std::vector::swap()``.
|
||||
std::vector<char> resume_data;
|
||||
|
||||
// to support the deprecated use case of reading the resume data into
|
||||
// resume_data field and getting a reject alert, any parse failure is
|
||||
// communicated forward into libtorrent via this field. If this is set, a
|
||||
// fastresume_rejected_alert will be posted.
|
||||
error_code internal_resume_data_error;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
|
|
@ -159,17 +159,18 @@ namespace libtorrent
|
|||
#ifndef TORRENT_NO_DEPRECATE
|
||||
namespace
|
||||
{
|
||||
void handle_backwards_compatible_resume_data(add_torrent_params& atp
|
||||
, error_code& ec)
|
||||
void handle_backwards_compatible_resume_data(add_torrent_params& atp)
|
||||
{
|
||||
// if there's no resume data set, there's nothing to do. It's either
|
||||
// using the previous API without resume data, or the resume data has
|
||||
// already been parsed out into the add_torrent_params struct.
|
||||
if (atp.resume_data.empty()) return;
|
||||
|
||||
error_code ec;
|
||||
add_torrent_params resume_data
|
||||
= read_resume_data(&atp.resume_data[0], atp.resume_data.size(), ec);
|
||||
|
||||
resume_data.internal_resume_data_error = ec;
|
||||
if (ec) return;
|
||||
|
||||
// now, merge resume_data into atp according to the merge flags
|
||||
|
@ -279,14 +280,13 @@ namespace libtorrent
|
|||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
torrent_handle session_handle::add_torrent(add_torrent_params const& params)
|
||||
{
|
||||
error_code ec;
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
add_torrent_params p = params;
|
||||
handle_backwards_compatible_resume_data(p, ec);
|
||||
if (ec) throw libtorrent_exception(ec);
|
||||
handle_backwards_compatible_resume_data(p);
|
||||
#else
|
||||
add_torrent_params const& p = params;
|
||||
#endif
|
||||
error_code ec;
|
||||
torrent_handle r = TORRENT_SYNC_CALL_RET2(torrent_handle, add_torrent, p, boost::ref(ec));
|
||||
if (ec) throw libtorrent_exception(ec);
|
||||
return r;
|
||||
|
@ -298,8 +298,7 @@ namespace libtorrent
|
|||
ec.clear();
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
add_torrent_params p = params;
|
||||
handle_backwards_compatible_resume_data(p, ec);
|
||||
if (ec) return torrent_handle();
|
||||
handle_backwards_compatible_resume_data(p);
|
||||
#else
|
||||
add_torrent_params const& p = params;
|
||||
#endif
|
||||
|
@ -311,14 +310,7 @@ namespace libtorrent
|
|||
add_torrent_params* p = new add_torrent_params(params);
|
||||
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
error_code ec;
|
||||
handle_backwards_compatible_resume_data(*p, ec);
|
||||
//TODO: 3 what should we do about error handling here?
|
||||
if (ec)
|
||||
{
|
||||
delete p;
|
||||
return;
|
||||
}
|
||||
handle_backwards_compatible_resume_data(*p);
|
||||
#endif
|
||||
|
||||
TORRENT_ASYNC_CALL1(async_add_torrent, p);
|
||||
|
|
|
@ -797,6 +797,16 @@ namespace libtorrent
|
|||
{
|
||||
TORRENT_ASSERT(is_single_thread());
|
||||
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
if (m_add_torrent_params
|
||||
&& m_add_torrent_params->internal_resume_data_error
|
||||
&& m_ses.alerts().should_post<fastresume_rejected_alert>())
|
||||
{
|
||||
m_ses.alerts().emplace_alert<fastresume_rejected_alert>(get_handle()
|
||||
, m_add_torrent_params->internal_resume_data_error, "", "");
|
||||
}
|
||||
#endif
|
||||
|
||||
// TODO: 3 why isn't this done in the constructor?
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
|
|
Loading…
Reference in New Issue