mirror of
https://github.com/codex-storage/deluge.git
synced 2025-02-16 21:36:40 +00:00
lt sync 3129
This commit is contained in:
parent
5c839a6b20
commit
d850b71561
@ -300,6 +300,7 @@ void bind_session()
|
|||||||
.def("stop_dht", allow_threads(&session::stop_dht), session_stop_dht_doc)
|
.def("stop_dht", allow_threads(&session::stop_dht), session_stop_dht_doc)
|
||||||
.def("dht_state", allow_threads(&session::dht_state), session_dht_state_doc)
|
.def("dht_state", allow_threads(&session::dht_state), session_dht_state_doc)
|
||||||
.def("set_dht_proxy", allow_threads(&session::set_dht_proxy))
|
.def("set_dht_proxy", allow_threads(&session::set_dht_proxy))
|
||||||
|
.def("dht_proxy", allow_threads(&session::dht_proxy), return_value_policy<copy_const_reference>())
|
||||||
#endif
|
#endif
|
||||||
.def("add_torrent", &add_torrent, session_add_torrent_doc)
|
.def("add_torrent", &add_torrent, session_add_torrent_doc)
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
@ -373,6 +374,9 @@ void bind_session()
|
|||||||
.def("set_peer_proxy", allow_threads(&session::set_peer_proxy))
|
.def("set_peer_proxy", allow_threads(&session::set_peer_proxy))
|
||||||
.def("set_tracker_proxy", allow_threads(&session::set_tracker_proxy))
|
.def("set_tracker_proxy", allow_threads(&session::set_tracker_proxy))
|
||||||
.def("set_web_seed_proxy", allow_threads(&session::set_web_seed_proxy))
|
.def("set_web_seed_proxy", allow_threads(&session::set_web_seed_proxy))
|
||||||
|
.def("peer_proxy", allow_threads(&session::peer_proxy), return_value_policy<copy_const_reference>())
|
||||||
|
.def("tracker_proxy", allow_threads(&session::tracker_proxy), return_value_policy<copy_const_reference>())
|
||||||
|
.def("web_seed_proxy", allow_threads(&session::web_seed_proxy), return_value_policy<copy_const_reference>())
|
||||||
.def("start_upnp", &start_upnp, session_start_upnp_doc)
|
.def("start_upnp", &start_upnp, session_start_upnp_doc)
|
||||||
.def("stop_upnp", allow_threads(&session::stop_upnp), session_stop_upnp_doc)
|
.def("stop_upnp", allow_threads(&session::stop_upnp), session_stop_upnp_doc)
|
||||||
.def("start_lsd", allow_threads(&session::start_lsd), session_start_lsd_doc)
|
.def("start_lsd", allow_threads(&session::start_lsd), session_start_lsd_doc)
|
||||||
|
@ -452,7 +452,7 @@ namespace libtorrent
|
|||||||
{
|
{
|
||||||
l.unlock();
|
l.unlock();
|
||||||
ret += p.storage->read_impl(p.blocks[i], p.piece, piece_offset, block_size);
|
ret += p.storage->read_impl(p.blocks[i], p.piece, piece_offset, block_size);
|
||||||
if (!p.storage->error()) { return -1; }
|
if (p.storage->error()) { return -1; }
|
||||||
l.lock();
|
l.lock();
|
||||||
++m_cache_stats.reads;
|
++m_cache_stats.reads;
|
||||||
}
|
}
|
||||||
|
@ -298,7 +298,7 @@ namespace libtorrent { namespace dht
|
|||||||
int peers = 0;
|
int peers = 0;
|
||||||
std::for_each(m_dht.begin_data(), m_dht.end_data(), count_peers(peers));
|
std::for_each(m_dht.begin_data(), m_dht.end_data(), count_peers(peers));
|
||||||
|
|
||||||
std::ofstream pc("libtorrent_logs/dht_stats.log", std::ios_base::app);
|
std::ofstream pc("libtorrent_logs/dht_stats.log", first ? std::ios_base::trunc : std::ios_base::app);
|
||||||
if (first)
|
if (first)
|
||||||
{
|
{
|
||||||
first = false;
|
first = false;
|
||||||
|
@ -263,7 +263,7 @@ bool rpc_manager::incoming(msg const& m)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TORRENT_DHT_VERBOSE_LOGGING
|
#ifdef TORRENT_DHT_VERBOSE_LOGGING
|
||||||
std::ofstream reply_stats("libtorrent_logs/round_trip_ms.log", std::ios::app);
|
std::ofstream reply_stats("round_trip_ms.log", std::ios::app);
|
||||||
reply_stats << m.addr << "\t" << total_milliseconds(time_now() - o->sent)
|
reply_stats << m.addr << "\t" << total_milliseconds(time_now() - o->sent)
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
@ -3421,6 +3421,8 @@ namespace libtorrent
|
|||||||
TORRENT_ASSERT(m_torrent_file->is_valid());
|
TORRENT_ASSERT(m_torrent_file->is_valid());
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
|
if (m_abort) return;
|
||||||
|
|
||||||
// we might be finished already, in which case we should
|
// we might be finished already, in which case we should
|
||||||
// not switch to downloading mode.
|
// not switch to downloading mode.
|
||||||
if (m_state != torrent_status::finished)
|
if (m_state != torrent_status::finished)
|
||||||
|
@ -74,13 +74,12 @@ namespace
|
|||||||
str += 0x80 | (chr & 0x3f);
|
str += 0x80 | (chr & 0x3f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void verify_encoding(file_entry& target)
|
bool verify_encoding(std::string& target)
|
||||||
{
|
{
|
||||||
std::string tmp_path;
|
std::string tmp_path;
|
||||||
std::string file_path = target.path.string();
|
|
||||||
bool valid_encoding = true;
|
bool valid_encoding = true;
|
||||||
for (std::string::iterator i = file_path.begin()
|
for (std::string::iterator i = target.begin()
|
||||||
, end(file_path.end()); i != end; ++i)
|
, end(target.end()); i != end; ++i)
|
||||||
{
|
{
|
||||||
// valid ascii-character
|
// valid ascii-character
|
||||||
if ((*i & 0x80) == 0)
|
if ((*i & 0x80) == 0)
|
||||||
@ -153,7 +152,14 @@ namespace
|
|||||||
// save the original encoding and replace the
|
// save the original encoding and replace the
|
||||||
// commonly used path with the correctly
|
// commonly used path with the correctly
|
||||||
// encoded string
|
// encoded string
|
||||||
if (!valid_encoding) target.path = tmp_path;
|
if (!valid_encoding) target = tmp_path;
|
||||||
|
return valid_encoding;
|
||||||
|
}
|
||||||
|
|
||||||
|
void verify_encoding(file_entry& target)
|
||||||
|
{
|
||||||
|
std::string p = target.path.string();
|
||||||
|
if (!verify_encoding(p)) target.path = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool extract_single_file(lazy_entry const& dict, file_entry& target
|
bool extract_single_file(lazy_entry const& dict, file_entry& target
|
||||||
@ -421,6 +427,9 @@ namespace libtorrent
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// correct utf-8 encoding errors
|
||||||
|
verify_encoding(name);
|
||||||
|
|
||||||
// extract file list
|
// extract file list
|
||||||
lazy_entry const* i = info.dict_find_list("files");
|
lazy_entry const* i = info.dict_find_list("files");
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
@ -573,9 +582,11 @@ namespace libtorrent
|
|||||||
|
|
||||||
m_comment = torrent_file.dict_find_string_value("comment.utf-8");
|
m_comment = torrent_file.dict_find_string_value("comment.utf-8");
|
||||||
if (m_comment.empty()) m_comment = torrent_file.dict_find_string_value("comment");
|
if (m_comment.empty()) m_comment = torrent_file.dict_find_string_value("comment");
|
||||||
|
verify_encoding(m_comment);
|
||||||
|
|
||||||
m_created_by = torrent_file.dict_find_string_value("created by.utf-8");
|
m_created_by = torrent_file.dict_find_string_value("created by.utf-8");
|
||||||
if (m_created_by.empty()) m_created_by = torrent_file.dict_find_string_value("created by");
|
if (m_created_by.empty()) m_created_by = torrent_file.dict_find_string_value("created by");
|
||||||
|
verify_encoding(m_created_by);
|
||||||
|
|
||||||
lazy_entry const* info = torrent_file.dict_find_dict("info");
|
lazy_entry const* info = torrent_file.dict_find_dict("info");
|
||||||
if (info == 0)
|
if (info == 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user