include name, save_path and torrent_file in torrent_status, for improved performance
This commit is contained in:
parent
de3dd9b0d9
commit
b07e7d8fe9
|
@ -1,3 +1,4 @@
|
||||||
|
* include name, save_path and torrent_file in torrent_status, for improved performance
|
||||||
* separate anonymous mode and force-proxy mode, and tighten it up a bit
|
* separate anonymous mode and force-proxy mode, and tighten it up a bit
|
||||||
* add per-tracker scrape information to announce_entry
|
* add per-tracker scrape information to announce_entry
|
||||||
* report errors in read_piece_alert
|
* report errors in read_piece_alert
|
||||||
|
|
|
@ -2338,7 +2338,10 @@ Its declaration looks like this::
|
||||||
query_accurate_download_counters = 2,
|
query_accurate_download_counters = 2,
|
||||||
query_last_seen_complete = 4,
|
query_last_seen_complete = 4,
|
||||||
query_pieces = 8,
|
query_pieces = 8,
|
||||||
query_verified_pieces = 16
|
query_verified_pieces = 16,
|
||||||
|
query_torrent_file = 32,
|
||||||
|
query_name = 64,
|
||||||
|
query_save_path = 128,
|
||||||
};
|
};
|
||||||
|
|
||||||
torrent_status status(boost::uint32_t flags = 0xffffffff);
|
torrent_status status(boost::uint32_t flags = 0xffffffff);
|
||||||
|
@ -2430,7 +2433,6 @@ Its declaration looks like this::
|
||||||
|
|
||||||
bool set_metadata(char const* buf, int size) const;
|
bool set_metadata(char const* buf, int size) const;
|
||||||
|
|
||||||
std::string save_path() const;
|
|
||||||
void move_storage(std::string const& save_path) const;
|
void move_storage(std::string const& save_path) const;
|
||||||
void move_storage(std::wstring const& save_path) const;
|
void move_storage(std::wstring const& save_path) const;
|
||||||
void rename_file(int index, std::string) const;
|
void rename_file(int index, std::string) const;
|
||||||
|
@ -2610,16 +2612,6 @@ the operation is a lot cheaper, since libtorrent already keeps track of this int
|
||||||
and no calculation is required.
|
and no calculation is required.
|
||||||
|
|
||||||
|
|
||||||
save_path()
|
|
||||||
-----------
|
|
||||||
|
|
||||||
::
|
|
||||||
|
|
||||||
std::string save_path() const;
|
|
||||||
|
|
||||||
``save_path()`` returns the path that was given to `async_add_torrent() add_torrent()`_ when this torrent
|
|
||||||
was started.
|
|
||||||
|
|
||||||
move_storage()
|
move_storage()
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
|
@ -2768,17 +2760,6 @@ the source mask of this peer. Typically this is one of the source flags in peer_
|
||||||
i.e. ``tracker``, ``pex``, ``dht`` etc.
|
i.e. ``tracker``, ``pex``, ``dht`` etc.
|
||||||
|
|
||||||
|
|
||||||
name()
|
|
||||||
------
|
|
||||||
|
|
||||||
::
|
|
||||||
|
|
||||||
std::string name() const;
|
|
||||||
|
|
||||||
Returns the name of the torrent. i.e. the name from the metadata associated with it. In
|
|
||||||
case the torrent was started without metadata, and hasn't completely received it yet,
|
|
||||||
it returns the name given to it when added to the session. See ``session::add_torrent``.
|
|
||||||
|
|
||||||
|
|
||||||
set_upload_limit() set_download_limit() upload_limit() download_limit()
|
set_upload_limit() set_download_limit() upload_limit() download_limit()
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
|
@ -3247,7 +3228,7 @@ Example code to pause and save resume data for all torrents and wait for the ale
|
||||||
}
|
}
|
||||||
|
|
||||||
torrent_handle h = rd->handle;
|
torrent_handle h = rd->handle;
|
||||||
std::ofstream out((h.save_path() + "/" + h.torrent_file()->name() + ".fastresume").c_str()
|
std::ofstream out((h.status().save_path + "/" + h.torrent_file()->name() + ".fastresume").c_str()
|
||||||
, std::ios_base::binary);
|
, std::ios_base::binary);
|
||||||
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);
|
||||||
|
@ -3309,6 +3290,16 @@ By default everything is included. The flags you can use to decide what to *incl
|
||||||
* ``query_verified_pieces``
|
* ``query_verified_pieces``
|
||||||
includes ``verified_pieces`` (only applies to torrents in *seed mode*).
|
includes ``verified_pieces`` (only applies to torrents in *seed mode*).
|
||||||
|
|
||||||
|
* ``query_torrent_file``
|
||||||
|
includes ``torrent_file``, which is all the static information from the .torrent file.
|
||||||
|
|
||||||
|
* ``query_name``
|
||||||
|
includes ``name``, the name of the torrent. This is either derived from the .torrent
|
||||||
|
file, or from the ``&dn=`` magnet link argument or possibly some other source. If the
|
||||||
|
name of the torrent is not known, this is an empty string.
|
||||||
|
|
||||||
|
* ``query_save_path``
|
||||||
|
includes ``save_path``, the path to the directory the files of the torrent are saved to.
|
||||||
|
|
||||||
get_download_queue()
|
get_download_queue()
|
||||||
--------------------
|
--------------------
|
||||||
|
@ -3493,6 +3484,10 @@ It contains the following fields::
|
||||||
float progress;
|
float progress;
|
||||||
int progress_ppm;
|
int progress_ppm;
|
||||||
std::string error;
|
std::string error;
|
||||||
|
std::string save_path;
|
||||||
|
std::string name;
|
||||||
|
|
||||||
|
boost::intrusive_ptr<const torrent_info> torrent_file;
|
||||||
|
|
||||||
boost::posix_time::time_duration next_announce;
|
boost::posix_time::time_duration next_announce;
|
||||||
boost::posix_time::time_duration announce_interval;
|
boost::posix_time::time_duration announce_interval;
|
||||||
|
@ -3665,6 +3660,19 @@ ip, a magnet link for instance).
|
||||||
case it was paused by an error. If the torrent is not paused or if it's paused but
|
case it was paused by an error. If the torrent is not paused or if it's paused but
|
||||||
not because of an error, this string is empty.
|
not because of an error, this string is empty.
|
||||||
|
|
||||||
|
``save_path`` is the path to the directory where this torrent's files are stored.
|
||||||
|
It's typically the path as was given to `async_add_torrent() add_torrent()`_ when this torrent
|
||||||
|
was started. This field is only included if the torrent status is queried with
|
||||||
|
``torrent_handle::query_save_path``.
|
||||||
|
|
||||||
|
``name`` is the name of the torrent. Typically this is derived from the .torrent file.
|
||||||
|
In case the torrent was started without metadata, and hasn't completely received it yet,
|
||||||
|
it returns the name given to it when added to the session. See ``session::add_torrent``.
|
||||||
|
This field is only included if the torrent status is queried with ``torrent_handle::query_name``.
|
||||||
|
|
||||||
|
``torrent_file`` is set to point to the ``torrent_info`` object for this torrent. It's
|
||||||
|
only included if the torrent status is queried with ``torrent_handle::query_torrent_file``.
|
||||||
|
|
||||||
``next_announce`` is the time until the torrent will announce itself to the tracker. And
|
``next_announce`` is the time until the torrent will announce itself to the tracker. And
|
||||||
``announce_interval`` is the time the tracker want us to wait until we announce ourself
|
``announce_interval`` is the time the tracker want us to wait until we announce ourself
|
||||||
again the next time.
|
again the next time.
|
||||||
|
|
|
@ -176,7 +176,10 @@ namespace libtorrent
|
||||||
query_accurate_download_counters = 2,
|
query_accurate_download_counters = 2,
|
||||||
query_last_seen_complete = 4,
|
query_last_seen_complete = 4,
|
||||||
query_pieces = 8,
|
query_pieces = 8,
|
||||||
query_verified_pieces = 16
|
query_verified_pieces = 16,
|
||||||
|
query_torrent_file = 32,
|
||||||
|
query_name = 64,
|
||||||
|
query_save_path = 128,
|
||||||
};
|
};
|
||||||
|
|
||||||
// the flags specify which fields are calculated. By default everything
|
// the flags specify which fields are calculated. By default everything
|
||||||
|
@ -270,6 +273,19 @@ namespace libtorrent
|
||||||
|
|
||||||
// ================ start deprecation ============
|
// ================ start deprecation ============
|
||||||
|
|
||||||
|
// deprecated in 1.0
|
||||||
|
// use status() instead (with query_save_path)
|
||||||
|
TORRENT_DEPRECATED_PREFIX
|
||||||
|
std::string save_path() const TORRENT_DEPRECATED;
|
||||||
|
|
||||||
|
// deprecated in 1.0
|
||||||
|
// use status() instead (with query_name)
|
||||||
|
// returns the name of this torrent, in case it doesn't
|
||||||
|
// have metadata it returns the name assigned to it
|
||||||
|
// when it was added.
|
||||||
|
TORRENT_DEPRECATED_PREFIX
|
||||||
|
std::string name() const TORRENT_DEPRECATED;
|
||||||
|
|
||||||
// use torrent_file() instead
|
// use torrent_file() instead
|
||||||
TORRENT_DEPRECATED_PREFIX
|
TORRENT_DEPRECATED_PREFIX
|
||||||
const torrent_info& get_torrent_info() const TORRENT_DEPRECATED;
|
const torrent_info& get_torrent_info() const TORRENT_DEPRECATED;
|
||||||
|
@ -366,11 +382,6 @@ namespace libtorrent
|
||||||
// performs a scrape request
|
// performs a scrape request
|
||||||
void scrape_tracker() const;
|
void scrape_tracker() const;
|
||||||
|
|
||||||
// returns the name of this torrent, in case it doesn't
|
|
||||||
// have metadata it returns the name assigned to it
|
|
||||||
// when it was added.
|
|
||||||
std::string name() const;
|
|
||||||
|
|
||||||
void set_upload_limit(int limit) const;
|
void set_upload_limit(int limit) const;
|
||||||
int upload_limit() const;
|
int upload_limit() const;
|
||||||
void set_download_limit(int limit) const;
|
void set_download_limit(int limit) const;
|
||||||
|
@ -381,8 +392,6 @@ namespace libtorrent
|
||||||
// manually connect a peer
|
// manually connect a peer
|
||||||
void connect_peer(tcp::endpoint const& adr, int source = 0) const;
|
void connect_peer(tcp::endpoint const& adr, int source = 0) const;
|
||||||
|
|
||||||
std::string save_path() const;
|
|
||||||
|
|
||||||
// -1 means unlimited unchokes
|
// -1 means unlimited unchokes
|
||||||
void set_max_uploads(int max_uploads) const;
|
void set_max_uploads(int max_uploads) const;
|
||||||
int max_uploads() const;
|
int max_uploads() const;
|
||||||
|
@ -470,6 +479,19 @@ namespace libtorrent
|
||||||
int progress_ppm;
|
int progress_ppm;
|
||||||
std::string error;
|
std::string error;
|
||||||
|
|
||||||
|
// save path of where the torrent's files are saved
|
||||||
|
// only set when status is queried with query_save_path
|
||||||
|
std::string save_path;
|
||||||
|
|
||||||
|
// name of the torrent, or empty if the torrent's name
|
||||||
|
// cannot be established yet
|
||||||
|
// only set when status is queried with query_name
|
||||||
|
std::string name;
|
||||||
|
|
||||||
|
// the torrent file for this torrent
|
||||||
|
// only set when status is queried with query_torrent_file
|
||||||
|
boost::intrusive_ptr<const torrent_info> torrent_file;
|
||||||
|
|
||||||
boost::posix_time::time_duration next_announce;
|
boost::posix_time::time_duration next_announce;
|
||||||
boost::posix_time::time_duration announce_interval;
|
boost::posix_time::time_duration announce_interval;
|
||||||
|
|
||||||
|
|
|
@ -8671,6 +8671,15 @@ namespace libtorrent
|
||||||
st->handle = get_handle();
|
st->handle = get_handle();
|
||||||
st->info_hash = info_hash();
|
st->info_hash = info_hash();
|
||||||
|
|
||||||
|
if (flags & torrent_handle::query_name)
|
||||||
|
st->name = name();
|
||||||
|
|
||||||
|
if (flags & torrent_handle::query_save_path)
|
||||||
|
st->save_path = save_path();
|
||||||
|
|
||||||
|
if (flags & torrent_handle::query_torrent_file)
|
||||||
|
st->torrent_file = m_torrent_file;
|
||||||
|
|
||||||
st->listen_port = 0;
|
st->listen_port = 0;
|
||||||
#ifdef TORRENT_USE_OPENSSL
|
#ifdef TORRENT_USE_OPENSSL
|
||||||
if (is_ssl_torrent()) st->listen_port = m_ses.ssl_listen_port();
|
if (is_ssl_torrent()) st->listen_port = m_ses.ssl_listen_port();
|
||||||
|
|
|
@ -528,13 +528,6 @@ namespace libtorrent
|
||||||
TORRENT_ASYNC_CALL1(set_sequential_download, sd);
|
TORRENT_ASYNC_CALL1(set_sequential_download, sd);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string torrent_handle::name() const
|
|
||||||
{
|
|
||||||
INVARIANT_CHECK;
|
|
||||||
TORRENT_SYNC_CALL_RET(std::string, "", name);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
void torrent_handle::piece_availability(std::vector<int>& avail) const
|
void torrent_handle::piece_availability(std::vector<int>& avail) const
|
||||||
{
|
{
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
@ -882,7 +875,6 @@ namespace libtorrent
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
std::string torrent_handle::save_path() const
|
std::string torrent_handle::save_path() const
|
||||||
{
|
{
|
||||||
|
@ -891,6 +883,15 @@ namespace libtorrent
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string torrent_handle::name() const
|
||||||
|
{
|
||||||
|
INVARIANT_CHECK;
|
||||||
|
TORRENT_SYNC_CALL_RET(std::string, "", name);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void torrent_handle::connect_peer(tcp::endpoint const& adr, int source) const
|
void torrent_handle::connect_peer(tcp::endpoint const& adr, int source) const
|
||||||
{
|
{
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
Loading…
Reference in New Issue