mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-03 15:08:40 +00:00
lt sync 2598
This commit is contained in:
parent
bf69584b99
commit
922e34f025
21 changed files with 137 additions and 60 deletions
|
@ -42,22 +42,18 @@ import xdg, xdg.BaseDirectory
|
||||||
LT_TORRENT_STATE = {
|
LT_TORRENT_STATE = {
|
||||||
"Queued": 0,
|
"Queued": 0,
|
||||||
"Checking": 1,
|
"Checking": 1,
|
||||||
"Connecting": 2,
|
"Downloading Metadata": 2,
|
||||||
"Downloading Metadata": 3,
|
"Downloading": 3,
|
||||||
"Downloading": 4,
|
"Finished": 4,
|
||||||
"Finished": 5,
|
"Seeding": 5,
|
||||||
"Seeding": 6,
|
"Allocating": 6,
|
||||||
"Allocating": 7,
|
|
||||||
"Paused": 8,
|
|
||||||
0: "Queued",
|
0: "Queued",
|
||||||
1: "Checking",
|
1: "Checking",
|
||||||
2: "Connecting",
|
2: "Downloading Metadata",
|
||||||
3: "Downloading Metadata",
|
3: "Downloading",
|
||||||
4: "Downloading",
|
4: "Finished",
|
||||||
5: "Finished",
|
5: "Seeding",
|
||||||
6: "Seeding",
|
6: "Allocating",
|
||||||
7: "Allocating",
|
|
||||||
8: "Paused"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TORRENT_STATE = [
|
TORRENT_STATE = [
|
||||||
|
|
|
@ -241,8 +241,7 @@ class Torrent:
|
||||||
if ltstate == LTSTATE["Queued"] or ltstate == LTSTATE["Checking"]:
|
if ltstate == LTSTATE["Queued"] or ltstate == LTSTATE["Checking"]:
|
||||||
self.state = "Checking"
|
self.state = "Checking"
|
||||||
return
|
return
|
||||||
elif ltstate == LTSTATE["Connecting"] or ltstate == LTSTATE["Downloading"] or\
|
elif ltstate == LTSTATE["Downloading"] or ltstate == LTSTATE["Downloading Metadata"]:
|
||||||
ltstate == LTSTATE["Downloading Metadata"]:
|
|
||||||
self.state = "Downloading"
|
self.state = "Downloading"
|
||||||
elif ltstate == LTSTATE["Finished"] or ltstate == LTSTATE["Seeding"]:
|
elif ltstate == LTSTATE["Finished"] or ltstate == LTSTATE["Seeding"]:
|
||||||
self.state = "Seeding"
|
self.state = "Seeding"
|
||||||
|
|
|
@ -96,7 +96,9 @@ namespace libtorrent {
|
||||||
virtual std::string message() const = 0;
|
virtual std::string message() const = 0;
|
||||||
virtual int category() const = 0;
|
virtual int category() const = 0;
|
||||||
|
|
||||||
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
severity_t severity() const TORRENT_DEPRECATED { return warning; }
|
severity_t severity() const TORRENT_DEPRECATED { return warning; }
|
||||||
|
#endif
|
||||||
|
|
||||||
virtual std::auto_ptr<alert> clone() const = 0;
|
virtual std::auto_ptr<alert> clone() const = 0;
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ std::string demangle(char const* name);
|
||||||
#if (defined __linux__ || defined __MACH__) && defined __GNUC__ && !defined(NDEBUG)
|
#if (defined __linux__ || defined __MACH__) && defined __GNUC__ && !defined(NDEBUG)
|
||||||
|
|
||||||
TORRENT_EXPORT void assert_fail(const char* expr, int line, char const* file, char const* function);
|
TORRENT_EXPORT void assert_fail(const char* expr, int line, char const* file, char const* function);
|
||||||
#define TORRENT_ASSERT(x) if (x) {} else assert_fail(#x, __LINE__, __FILE__, __PRETTY_FUNCTION__)
|
#define TORRENT_ASSERT(x) do { if (x) {} else assert_fail(#x, __LINE__, __FILE__, __PRETTY_FUNCTION__); } while (false)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
|
@ -78,10 +78,12 @@ namespace libtorrent
|
||||||
void add_url_seed(std::string const& url);
|
void add_url_seed(std::string const& url);
|
||||||
void add_node(std::pair<std::string, int> const& node);
|
void add_node(std::pair<std::string, int> const& node);
|
||||||
void add_tracker(std::string const& url, int tier = 0);
|
void add_tracker(std::string const& url, int tier = 0);
|
||||||
|
void set_priv(bool p) { m_private = p; }
|
||||||
|
|
||||||
int num_pieces() const { return m_files.num_pieces(); }
|
int num_pieces() const { return m_files.num_pieces(); }
|
||||||
int piece_length() const { return m_files.piece_length(); }
|
int piece_length() const { return m_files.piece_length(); }
|
||||||
int piece_size(int i) const { return m_files.piece_size(i); }
|
int piece_size(int i) const { return m_files.piece_size(i); }
|
||||||
|
bool priv() const { return m_private; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -47,12 +47,18 @@ namespace libtorrent
|
||||||
|
|
||||||
std::string TORRENT_EXPORT make_magnet_uri(torrent_handle const& handle);
|
std::string TORRENT_EXPORT make_magnet_uri(torrent_handle const& handle);
|
||||||
|
|
||||||
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
|
// deprecated in 0.14
|
||||||
torrent_handle TORRENT_EXPORT add_magnet_uri(session& ses, std::string const& uri
|
torrent_handle TORRENT_EXPORT add_magnet_uri(session& ses, std::string const& uri
|
||||||
, fs::path const& save_path
|
, fs::path const& save_path
|
||||||
, storage_mode_t storage_mode = storage_mode_sparse
|
, storage_mode_t storage_mode = storage_mode_sparse
|
||||||
, bool paused = false
|
, bool paused = false
|
||||||
, storage_constructor_type sc = default_storage_constructor
|
, storage_constructor_type sc = default_storage_constructor
|
||||||
, void* userdata = 0);
|
, void* userdata = 0) TORRENT_DEPRECATED;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
torrent_handle TORRENT_EXPORT add_magnet_uri(session& ses, std::string const& uri
|
||||||
|
, add_torrent_params p);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -179,6 +179,7 @@ namespace libtorrent
|
||||||
// all torrent_handles must be destructed before the session is destructed!
|
// all torrent_handles must be destructed before the session is destructed!
|
||||||
torrent_handle add_torrent(add_torrent_params const& params);
|
torrent_handle add_torrent(add_torrent_params const& params);
|
||||||
|
|
||||||
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
// deprecated in 0.14
|
// deprecated in 0.14
|
||||||
torrent_handle add_torrent(
|
torrent_handle add_torrent(
|
||||||
torrent_info const& ti
|
torrent_info const& ti
|
||||||
|
@ -209,6 +210,7 @@ namespace libtorrent
|
||||||
, bool paused = false
|
, bool paused = false
|
||||||
, storage_constructor_type sc = default_storage_constructor
|
, storage_constructor_type sc = default_storage_constructor
|
||||||
, void* userdata = 0) TORRENT_DEPRECATED;
|
, void* userdata = 0) TORRENT_DEPRECATED;
|
||||||
|
#endif
|
||||||
|
|
||||||
session_proxy abort() { return session_proxy(m_impl); }
|
session_proxy abort() { return session_proxy(m_impl); }
|
||||||
|
|
||||||
|
@ -317,7 +319,9 @@ namespace libtorrent
|
||||||
void set_max_half_open_connections(int limit);
|
void set_max_half_open_connections(int limit);
|
||||||
|
|
||||||
std::auto_ptr<alert> pop_alert();
|
std::auto_ptr<alert> pop_alert();
|
||||||
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
void set_severity_level(alert::severity_t s) TORRENT_DEPRECATED;
|
void set_severity_level(alert::severity_t s) TORRENT_DEPRECATED;
|
||||||
|
#endif
|
||||||
void set_alert_mask(int m);
|
void set_alert_mask(int m);
|
||||||
|
|
||||||
alert const* wait_for_alert(time_duration max_wait);
|
alert const* wait_for_alert(time_duration max_wait);
|
||||||
|
|
|
@ -140,6 +140,7 @@ namespace libtorrent
|
||||||
, auto_scrape_interval(1800)
|
, auto_scrape_interval(1800)
|
||||||
, auto_scrape_min_interval(300)
|
, auto_scrape_min_interval(300)
|
||||||
, max_peerlist_size(8000)
|
, max_peerlist_size(8000)
|
||||||
|
, min_announce_interval(5 * 60)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
// this is the user agent that will be sent to the tracker
|
// this is the user agent that will be sent to the tracker
|
||||||
|
@ -430,6 +431,11 @@ namespace libtorrent
|
||||||
// per torrent. This is the peers we know
|
// per torrent. This is the peers we know
|
||||||
// about, not necessarily connected to.
|
// about, not necessarily connected to.
|
||||||
int max_peerlist_size;
|
int max_peerlist_size;
|
||||||
|
|
||||||
|
// any announce intervals reported from a tracker
|
||||||
|
// that is lower than this, will be clamped to this
|
||||||
|
// value. It's specified in seconds
|
||||||
|
int min_announce_interval;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_DHT
|
#ifndef TORRENT_DISABLE_DHT
|
||||||
|
|
|
@ -126,7 +126,6 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
queued_for_checking,
|
queued_for_checking,
|
||||||
checking_files,
|
checking_files,
|
||||||
connecting_to_tracker,
|
|
||||||
downloading_metadata,
|
downloading_metadata,
|
||||||
downloading,
|
downloading,
|
||||||
finished,
|
finished,
|
||||||
|
@ -319,10 +318,12 @@ namespace libtorrent
|
||||||
torrent_status status() const;
|
torrent_status status() const;
|
||||||
void get_download_queue(std::vector<partial_piece_info>& queue) const;
|
void get_download_queue(std::vector<partial_piece_info>& queue) const;
|
||||||
|
|
||||||
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
// fills the specified vector with the download progress [0, 1]
|
// fills the specified vector with the download progress [0, 1]
|
||||||
// of each file in the torrent. The files are ordered as in
|
// of each file in the torrent. The files are ordered as in
|
||||||
// the torrent_info.
|
// the torrent_info.
|
||||||
void file_progress(std::vector<float>& progress) const TORRENT_DEPRECATED;
|
void file_progress(std::vector<float>& progress) const TORRENT_DEPRECATED;
|
||||||
|
#endif
|
||||||
void file_progress(std::vector<size_type>& progress) const;
|
void file_progress(std::vector<size_type>& progress) const;
|
||||||
|
|
||||||
void clear_error() const;
|
void clear_error() const;
|
||||||
|
@ -370,6 +371,7 @@ namespace libtorrent
|
||||||
|
|
||||||
// ================ start deprecation ============
|
// ================ start deprecation ============
|
||||||
|
|
||||||
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
// deprecated in 0.13
|
// deprecated in 0.13
|
||||||
// marks the piece with the given index as filtered
|
// marks the piece with the given index as filtered
|
||||||
// it will not be downloaded
|
// it will not be downloaded
|
||||||
|
@ -382,6 +384,7 @@ namespace libtorrent
|
||||||
void filter_files(std::vector<bool> const& files) const TORRENT_DEPRECATED;
|
void filter_files(std::vector<bool> const& files) const TORRENT_DEPRECATED;
|
||||||
|
|
||||||
// ================ end deprecation ============
|
// ================ end deprecation ============
|
||||||
|
#endif
|
||||||
|
|
||||||
void piece_availability(std::vector<int>& avail) const;
|
void piece_availability(std::vector<int>& avail) const;
|
||||||
|
|
||||||
|
@ -403,10 +406,12 @@ namespace libtorrent
|
||||||
// to.
|
// to.
|
||||||
void use_interface(const char* net_interface) const;
|
void use_interface(const char* net_interface) const;
|
||||||
|
|
||||||
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
// deprecated in 0.14
|
// deprecated in 0.14
|
||||||
// use save_resume_data() instead. It is async. and
|
// use save_resume_data() instead. It is async. and
|
||||||
// will return the resume data in an alert
|
// will return the resume data in an alert
|
||||||
entry write_resume_data() const TORRENT_DEPRECATED;
|
entry write_resume_data() const TORRENT_DEPRECATED;
|
||||||
|
#endif
|
||||||
|
|
||||||
// forces this torrent to reannounce
|
// forces this torrent to reannounce
|
||||||
// (make a rerequest from the tracker)
|
// (make a rerequest from the tracker)
|
||||||
|
|
|
@ -125,11 +125,13 @@ namespace libtorrent
|
||||||
peer_request map_file(int file, size_type offset, int size) const
|
peer_request map_file(int file, size_type offset, int size) const
|
||||||
{ return m_files.map_file(file, offset, size); }
|
{ return m_files.map_file(file, offset, size); }
|
||||||
|
|
||||||
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
// ------- start deprecation -------
|
// ------- start deprecation -------
|
||||||
// these functions will be removed in a future version
|
// these functions will be removed in a future version
|
||||||
torrent_info(entry const& torrent_file) TORRENT_DEPRECATED;
|
torrent_info(entry const& torrent_file) TORRENT_DEPRECATED;
|
||||||
void print(std::ostream& os) const TORRENT_DEPRECATED;
|
void print(std::ostream& os) const TORRENT_DEPRECATED;
|
||||||
// ------- end deprecation -------
|
// ------- end deprecation -------
|
||||||
|
#endif
|
||||||
|
|
||||||
bool is_valid() const { return m_files.is_valid(); }
|
bool is_valid() const { return m_files.is_valid(); }
|
||||||
|
|
||||||
|
|
|
@ -617,6 +617,7 @@ namespace libtorrent
|
||||||
size -= to_copy;
|
size -= to_copy;
|
||||||
block_offset = 0;
|
block_offset = 0;
|
||||||
buffer_offset += to_copy;
|
buffer_offset += to_copy;
|
||||||
|
++block;
|
||||||
}
|
}
|
||||||
ret = j.buffer_size;
|
ret = j.buffer_size;
|
||||||
++m_cache_stats.blocks_read;
|
++m_cache_stats.blocks_read;
|
||||||
|
@ -1153,7 +1154,8 @@ namespace libtorrent
|
||||||
#ifndef BOOST_NO_EXCEPTIONS
|
#ifndef BOOST_NO_EXCEPTIONS
|
||||||
try {
|
try {
|
||||||
#endif
|
#endif
|
||||||
TORRENT_ASSERT(ret != -2 || !j.str.empty());
|
TORRENT_ASSERT(ret != -2 || !j.str.empty()
|
||||||
|
|| j.action == disk_io_job::hash);
|
||||||
if (handler) m_ios.post(bind(handler, ret, j));
|
if (handler) m_ios.post(bind(handler, ret, j));
|
||||||
#ifndef BOOST_NO_EXCEPTIONS
|
#ifndef BOOST_NO_EXCEPTIONS
|
||||||
} catch (std::exception&)
|
} catch (std::exception&)
|
||||||
|
|
|
@ -201,8 +201,12 @@ namespace libtorrent
|
||||||
#else
|
#else
|
||||||
// rely on default umask to filter x and w permissions
|
// rely on default umask to filter x and w permissions
|
||||||
// for group and others
|
// for group and others
|
||||||
|
int permissions = S_IRUSR | S_IWUSR
|
||||||
|
| S_IRGRP | S_IWGRP
|
||||||
|
| S_IROTH | S_IWOTH;
|
||||||
|
|
||||||
m_fd = ::open(path.native_file_string().c_str()
|
m_fd = ::open(path.native_file_string().c_str()
|
||||||
, map_open_mode(mode.m_mask), S_IRWXU | S_IRWXG | S_IRWXO);
|
, map_open_mode(mode.m_mask), permissions);
|
||||||
|
|
||||||
if (m_fd == -1)
|
if (m_fd == -1)
|
||||||
{
|
{
|
||||||
|
|
|
@ -167,6 +167,7 @@ namespace
|
||||||
, {"HL", "Halite"}
|
, {"HL", "Halite"}
|
||||||
, {"HN", "Hydranode"}
|
, {"HN", "Hydranode"}
|
||||||
, {"KT", "KTorrent"}
|
, {"KT", "KTorrent"}
|
||||||
|
, {"LC", "LeechCraft"}
|
||||||
, {"LK", "Linkage"}
|
, {"LK", "Linkage"}
|
||||||
, {"LP", "lphant"}
|
, {"LP", "lphant"}
|
||||||
, {"LT", "libtorrent"}
|
, {"LT", "libtorrent"}
|
||||||
|
|
|
@ -69,6 +69,7 @@ namespace libtorrent
|
||||||
return ret.str();
|
return ret.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
torrent_handle add_magnet_uri(session& ses, std::string const& uri
|
torrent_handle add_magnet_uri(session& ses, std::string const& uri
|
||||||
, fs::path const& save_path
|
, fs::path const& save_path
|
||||||
, storage_mode_t storage_mode
|
, storage_mode_t storage_mode
|
||||||
|
@ -95,6 +96,31 @@ namespace libtorrent
|
||||||
, name.empty() ? 0 : name.c_str(), save_path, entry()
|
, name.empty() ? 0 : name.c_str(), save_path, entry()
|
||||||
, storage_mode, paused, sc, userdata);
|
, storage_mode, paused, sc, userdata);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
torrent_handle add_magnet_uri(session& ses, std::string const& uri
|
||||||
|
, add_torrent_params p)
|
||||||
|
{
|
||||||
|
std::string name;
|
||||||
|
std::string tracker;
|
||||||
|
|
||||||
|
boost::optional<std::string> display_name = url_has_argument(uri, "dn");
|
||||||
|
if (display_name) name = unescape_string(display_name->c_str());
|
||||||
|
boost::optional<std::string> tracker_string = url_has_argument(uri, "tr");
|
||||||
|
if (tracker_string) tracker = unescape_string(tracker_string->c_str());
|
||||||
|
|
||||||
|
boost::optional<std::string> btih = url_has_argument(uri, "xt");
|
||||||
|
if (!btih) return torrent_handle();
|
||||||
|
|
||||||
|
if (btih->compare(0, 9, "urn:btih:") != 0) return torrent_handle();
|
||||||
|
|
||||||
|
sha1_hash info_hash(base32decode(btih->substr(9)));
|
||||||
|
|
||||||
|
if (!tracker.empty()) p.tracker_url = tracker.c_str();
|
||||||
|
p.info_hash = info_hash;
|
||||||
|
if (!name.empty()) p.name = name.c_str();
|
||||||
|
return ses.add_torrent(p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -177,15 +177,15 @@ void natpmp::try_next_mapping(int i)
|
||||||
|
|
||||||
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
|
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
|
||||||
ptime now = time_now();
|
ptime now = time_now();
|
||||||
for (std::vector<mapping_t>::iterator i = m_mappings.begin()
|
for (std::vector<mapping_t>::iterator m = m_mappings.begin()
|
||||||
, end(m_mappings.end()); i != end; ++i)
|
, end(m_mappings.end()); m != end; ++m)
|
||||||
{
|
{
|
||||||
m_log << " " << (i - m_mappings.begin()) << " [ "
|
m_log << " " << (m - m_mappings.begin()) << " [ "
|
||||||
"proto: " << (i->protocol == none ? "none" : i->protocol == tcp ? "tcp" : "udp")
|
"proto: " << (m->protocol == none ? "none" : m->protocol == tcp ? "tcp" : "udp")
|
||||||
<< " port: " << i->external_port
|
<< " port: " << m->external_port
|
||||||
<< " local-port: " << i->local_port
|
<< " local-port: " << m->local_port
|
||||||
<< " action: " << (i->action == mapping_t::action_none ? "none" : i->action == mapping_t::action_add ? "add" : "delete")
|
<< " action: " << (m->action == mapping_t::action_none ? "none" : m->action == mapping_t::action_add ? "add" : "delete")
|
||||||
<< " ttl: " << total_seconds(i->expires - now)
|
<< " ttl: " << total_seconds(m->expires - now)
|
||||||
<< " ]" << std::endl;
|
<< " ]" << std::endl;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1212,14 +1212,16 @@ namespace libtorrent
|
||||||
// if this is a web seed. we don't have a peer_info struct
|
// if this is a web seed. we don't have a peer_info struct
|
||||||
if (m_peer_info) m_peer_info->seed = true;
|
if (m_peer_info) m_peer_info->seed = true;
|
||||||
m_upload_only = true;
|
m_upload_only = true;
|
||||||
disconnect_if_redundant();
|
|
||||||
if (is_disconnecting()) return;
|
|
||||||
|
|
||||||
m_have_piece.set_all();
|
m_have_piece.set_all();
|
||||||
m_num_pieces = num_pieces;
|
m_num_pieces = num_pieces;
|
||||||
t->peer_has_all();
|
t->peer_has_all();
|
||||||
if (!t->is_finished())
|
if (!t->is_finished())
|
||||||
t->get_policy().peer_is_interesting(*this);
|
t->get_policy().peer_is_interesting(*this);
|
||||||
|
|
||||||
|
disconnect_if_redundant();
|
||||||
|
if (is_disconnecting()) return;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1841,6 +1843,10 @@ namespace libtorrent
|
||||||
// (since it doesn't exist yet)
|
// (since it doesn't exist yet)
|
||||||
if (!t->ready_for_connections())
|
if (!t->ready_for_connections())
|
||||||
{
|
{
|
||||||
|
// assume seeds are interesting when we
|
||||||
|
// don't even have the metadata
|
||||||
|
t->get_policy().peer_is_interesting(*this);
|
||||||
|
|
||||||
disconnect_if_redundant();
|
disconnect_if_redundant();
|
||||||
// TODO: this might need something more
|
// TODO: this might need something more
|
||||||
// so that once we have the metadata
|
// so that once we have the metadata
|
||||||
|
@ -3710,13 +3716,13 @@ namespace libtorrent
|
||||||
#ifdef TORRENT_EXPENSIVE_INVARIANT_CHECKS
|
#ifdef TORRENT_EXPENSIVE_INVARIANT_CHECKS
|
||||||
if (m_peer_info)
|
if (m_peer_info)
|
||||||
{
|
{
|
||||||
policy::const_iterator i;
|
policy::const_iterator i = t->get_policy().begin_peer();
|
||||||
for (i = t->get_policy().begin_peer()
|
policy::const_iterator end = t->get_policy().end_peer();
|
||||||
, end(t->get_policy().end_peer()); i != end; ++i)
|
for (; i != end; ++i)
|
||||||
{
|
{
|
||||||
if (&i->second == m_peer_info) break;
|
if (&i->second == m_peer_info) break;
|
||||||
}
|
}
|
||||||
TORRENT_ASSERT(i != t->get_policy().end_peer());
|
TORRENT_ASSERT(i != end);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (t->has_picker() && !t->is_aborted())
|
if (t->has_picker() && !t->is_aborted())
|
||||||
|
|
|
@ -222,6 +222,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef TORRENT_PICKER_LOG
|
||||||
void piece_picker::print_pieces() const
|
void piece_picker::print_pieces() const
|
||||||
{
|
{
|
||||||
for (std::vector<int>::const_iterator i = m_priority_boundries.begin()
|
for (std::vector<int>::const_iterator i = m_priority_boundries.begin()
|
||||||
|
@ -245,6 +246,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void piece_picker::check_invariant(const torrent* t) const
|
void piece_picker::check_invariant(const torrent* t) const
|
||||||
{
|
{
|
||||||
|
@ -511,7 +513,7 @@ namespace libtorrent
|
||||||
priority_range(priority, &range_start, &range_end);
|
priority_range(priority, &range_start, &range_end);
|
||||||
int new_index;
|
int new_index;
|
||||||
if (range_end == range_start) new_index = range_start;
|
if (range_end == range_start) new_index = range_start;
|
||||||
else new_index = rand() % (range_end - range_start) + range_start;
|
else new_index = rand() % (range_end - range_start + 1) + range_start;
|
||||||
|
|
||||||
#ifdef TORRENT_PICKER_LOG
|
#ifdef TORRENT_PICKER_LOG
|
||||||
std::cerr << "add " << index << " (" << priority << ")" << std::endl;
|
std::cerr << "add " << index << " (" << priority << ")" << std::endl;
|
||||||
|
|
|
@ -244,6 +244,7 @@ namespace libtorrent
|
||||||
return m_impl->add_torrent(params);
|
return m_impl->add_torrent(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
// if the torrent already exists, this will throw duplicate_torrent
|
// if the torrent already exists, this will throw duplicate_torrent
|
||||||
torrent_handle session::add_torrent(
|
torrent_handle session::add_torrent(
|
||||||
torrent_info const& ti
|
torrent_info const& ti
|
||||||
|
@ -311,6 +312,7 @@ namespace libtorrent
|
||||||
p.userdata = userdata;
|
p.userdata = userdata;
|
||||||
return m_impl->add_torrent(p);
|
return m_impl->add_torrent(p);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void session::remove_torrent(const torrent_handle& h, int options)
|
void session::remove_torrent(const torrent_handle& h, int options)
|
||||||
{
|
{
|
||||||
|
@ -518,6 +520,7 @@ namespace libtorrent
|
||||||
m_impl->set_alert_mask(m);
|
m_impl->set_alert_mask(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
void session::set_severity_level(alert::severity_t s)
|
void session::set_severity_level(alert::severity_t s)
|
||||||
{
|
{
|
||||||
int m = 0;
|
int m = 0;
|
||||||
|
@ -535,6 +538,7 @@ namespace libtorrent
|
||||||
|
|
||||||
m_impl->set_alert_mask(m);
|
m_impl->set_alert_mask(m);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void session::start_lsd()
|
void session::start_lsd()
|
||||||
{
|
{
|
||||||
|
|
|
@ -848,6 +848,8 @@ namespace libtorrent
|
||||||
|
|
||||||
restart_tracker_timer(time_now() + seconds(tracker_retry_delay_max));
|
restart_tracker_timer(time_now() + seconds(tracker_retry_delay_max));
|
||||||
|
|
||||||
|
if (m_abort) e = tracker_request::stopped;
|
||||||
|
|
||||||
if (e == tracker_request::none)
|
if (e == tracker_request::none)
|
||||||
{
|
{
|
||||||
if (!m_start_sent) e = tracker_request::started;
|
if (!m_start_sent) e = tracker_request::started;
|
||||||
|
@ -962,9 +964,9 @@ namespace libtorrent
|
||||||
m_complete_sent = true;
|
m_complete_sent = true;
|
||||||
|
|
||||||
m_failed_trackers = 0;
|
m_failed_trackers = 0;
|
||||||
// announce intervals less than 5 minutes
|
|
||||||
// are insane.
|
if (interval < m_ses.settings().min_announce_interval)
|
||||||
if (interval < 60 * 5) interval = 60 * 5;
|
interval = m_ses.settings().min_announce_interval;
|
||||||
|
|
||||||
m_last_working_tracker
|
m_last_working_tracker
|
||||||
= prioritize_tracker(m_currently_trying_tracker);
|
= prioritize_tracker(m_currently_trying_tracker);
|
||||||
|
@ -1016,17 +1018,6 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (m_ses.m_ip_filter.access(a.address()) & ip_filter::blocked)
|
|
||||||
{
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
|
||||||
debug_log("blocked ip from tracker: " + i->ip);
|
|
||||||
#endif
|
|
||||||
if (m_ses.m_alerts.should_post<peer_blocked_alert>())
|
|
||||||
m_ses.m_alerts.post_alert(peer_blocked_alert(a.address()));
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_policy.peer_from_tracker(a, i->pid, peer_info::tracker, 0);
|
m_policy.peer_from_tracker(a, i->pid, peer_info::tracker, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3272,7 +3263,7 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT(m_torrent_file->is_valid());
|
TORRENT_ASSERT(m_torrent_file->is_valid());
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
set_state(torrent_status::connecting_to_tracker);
|
set_state(torrent_status::downloading);
|
||||||
|
|
||||||
if (!is_seed())
|
if (!is_seed())
|
||||||
{
|
{
|
||||||
|
@ -3404,6 +3395,20 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
|
||||||
|
|
||||||
|
if (!m_ses.m_queued_for_checking.empty())
|
||||||
|
{
|
||||||
|
// if there are torrents waiting to be checked
|
||||||
|
// assert that there's a torrent that is being
|
||||||
|
// processed right now
|
||||||
|
int found = 0;
|
||||||
|
for (aux::session_impl::torrent_map::iterator i = m_ses.m_torrents.begin()
|
||||||
|
, end(m_ses.m_torrents.end()); i != end; ++i)
|
||||||
|
if (i->second->m_state == torrent_status::checking_files) ++found;
|
||||||
|
// the case of 2 is in the special case where one switches over from
|
||||||
|
// checking to complete
|
||||||
|
TORRENT_ASSERT(found == 1 || found == 2);
|
||||||
|
}
|
||||||
|
|
||||||
TORRENT_ASSERT(m_resume_entry.type() == lazy_entry::dict_t
|
TORRENT_ASSERT(m_resume_entry.type() == lazy_entry::dict_t
|
||||||
|| m_resume_entry.type() == lazy_entry::none_t);
|
|| m_resume_entry.type() == lazy_entry::none_t);
|
||||||
|
|
||||||
|
@ -3466,7 +3471,7 @@ namespace libtorrent
|
||||||
for (policy::const_iterator i = m_policy.begin_peer()
|
for (policy::const_iterator i = m_policy.begin_peer()
|
||||||
, end(m_policy.end_peer()); i != end; ++i)
|
, end(m_policy.end_peer()); i != end; ++i)
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(i->second.ip.address() == i->first);
|
TORRENT_ASSERT(i->second.addr == i->first);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -4144,7 +4149,6 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT(valid_metadata());
|
TORRENT_ASSERT(valid_metadata());
|
||||||
|
|
||||||
fp.resize(m_torrent_file->num_files(), 0);
|
fp.resize(m_torrent_file->num_files(), 0);
|
||||||
TORRENT_ASSERT(has_picker());
|
|
||||||
|
|
||||||
if (is_seed())
|
if (is_seed())
|
||||||
{
|
{
|
||||||
|
@ -4153,6 +4157,8 @@ namespace libtorrent
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TORRENT_ASSERT(has_picker());
|
||||||
|
|
||||||
for (int i = 0; i < m_torrent_file->num_files(); ++i)
|
for (int i = 0; i < m_torrent_file->num_files(); ++i)
|
||||||
{
|
{
|
||||||
peer_request ret = m_torrent_file->files().map_file(i, 0, 0);
|
peer_request ret = m_torrent_file->files().map_file(i, 0, 0);
|
||||||
|
@ -4367,11 +4373,7 @@ namespace libtorrent
|
||||||
|
|
||||||
if (!valid_metadata())
|
if (!valid_metadata())
|
||||||
{
|
{
|
||||||
if (m_got_tracker_response == false && m_connections.empty())
|
st.state = torrent_status::downloading_metadata;
|
||||||
st.state = torrent_status::connecting_to_tracker;
|
|
||||||
else
|
|
||||||
st.state = torrent_status::downloading_metadata;
|
|
||||||
|
|
||||||
st.progress = m_progress;
|
st.progress = m_progress;
|
||||||
st.block_size = 0;
|
st.block_size = 0;
|
||||||
return st;
|
return st;
|
||||||
|
|
|
@ -332,11 +332,13 @@ namespace libtorrent
|
||||||
TORRENT_FORWARD(set_tracker_login(name, password));
|
TORRENT_FORWARD(set_tracker_login(name, password));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
void torrent_handle::file_progress(std::vector<float>& progress) const
|
void torrent_handle::file_progress(std::vector<float>& progress) const
|
||||||
{
|
{
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
TORRENT_FORWARD(file_progress(progress));
|
TORRENT_FORWARD(file_progress(progress));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void torrent_handle::file_progress(std::vector<size_type>& progress) const
|
void torrent_handle::file_progress(std::vector<size_type>& progress) const
|
||||||
{
|
{
|
||||||
|
@ -426,6 +428,7 @@ namespace libtorrent
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
// ============ start deprecation ===============
|
// ============ start deprecation ===============
|
||||||
|
|
||||||
void torrent_handle::filter_piece(int index, bool filter) const
|
void torrent_handle::filter_piece(int index, bool filter) const
|
||||||
|
@ -461,7 +464,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============ end deprecation ===============
|
// ============ end deprecation ===============
|
||||||
|
#endif
|
||||||
|
|
||||||
std::vector<announce_entry> const& torrent_handle::trackers() const
|
std::vector<announce_entry> const& torrent_handle::trackers() const
|
||||||
{
|
{
|
||||||
|
@ -525,6 +528,7 @@ namespace libtorrent
|
||||||
return !m_torrent.expired();
|
return !m_torrent.expired();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
entry torrent_handle::write_resume_data() const
|
entry torrent_handle::write_resume_data() const
|
||||||
{
|
{
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
@ -535,7 +539,7 @@ namespace libtorrent
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
fs::path torrent_handle::save_path() const
|
fs::path torrent_handle::save_path() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -227,6 +227,7 @@ namespace libtorrent
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
// standard constructor that parses a torrent file
|
// standard constructor that parses a torrent file
|
||||||
torrent_info::torrent_info(entry const& torrent_file)
|
torrent_info::torrent_info(entry const& torrent_file)
|
||||||
: m_creation_date(pt::ptime(pt::not_a_date_time))
|
: m_creation_date(pt::ptime(pt::not_a_date_time))
|
||||||
|
@ -249,6 +250,7 @@ namespace libtorrent
|
||||||
parse_torrent_file(e, error);
|
parse_torrent_file(e, error);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
torrent_info::torrent_info(lazy_entry const& torrent_file)
|
torrent_info::torrent_info(lazy_entry const& torrent_file)
|
||||||
: m_creation_date(pt::ptime(pt::not_a_date_time))
|
: m_creation_date(pt::ptime(pt::not_a_date_time))
|
||||||
|
@ -583,6 +585,7 @@ namespace libtorrent
|
||||||
, bind(&announce_entry::tier, _1), bind(&announce_entry::tier, _2)));
|
, bind(&announce_entry::tier, _1), bind(&announce_entry::tier, _2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
// ------- start deprecation -------
|
// ------- start deprecation -------
|
||||||
|
|
||||||
void torrent_info::print(std::ostream& os) const
|
void torrent_info::print(std::ostream& os) const
|
||||||
|
@ -606,6 +609,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------- end deprecation -------
|
// ------- end deprecation -------
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue