mirror of
https://github.com/codex-storage/deluge.git
synced 2025-01-28 04:04:47 +00:00
libtorrent sync 1449
This commit is contained in:
parent
ed9a306cf5
commit
da8bd07ce7
@ -37,6 +37,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
#if defined(__GNUC__) && __GNUC__ >= 4
|
#if defined(__GNUC__) && __GNUC__ >= 4
|
||||||
|
|
||||||
|
#define TORRENT_DEPRECATED __attribute__ ((deprecated))
|
||||||
|
|
||||||
# if defined(TORRENT_BUILDING_SHARED) || defined(TORRENT_LINKING_SHARED)
|
# if defined(TORRENT_BUILDING_SHARED) || defined(TORRENT_LINKING_SHARED)
|
||||||
# define TORRENT_EXPORT __attribute__ ((visibility("default")))
|
# define TORRENT_EXPORT __attribute__ ((visibility("default")))
|
||||||
# else
|
# else
|
||||||
@ -61,6 +63,9 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||||||
# define TORRENT_EXPORT
|
# define TORRENT_EXPORT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef TORRENT_DEPRECATED
|
||||||
|
#define TORRENT_DEPRECATED
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // TORRENT_CONFIG_HPP_INCLUDED
|
#endif // TORRENT_CONFIG_HPP_INCLUDED
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iosfwd>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -163,7 +163,9 @@ namespace libtorrent
|
|||||||
void we_have(int index);
|
void we_have(int index);
|
||||||
|
|
||||||
// sets the priority of a piece.
|
// sets the priority of a piece.
|
||||||
void set_piece_priority(int index, int prio);
|
// returns true if the priority was changed from 0 to non-0
|
||||||
|
// or vice versa
|
||||||
|
bool set_piece_priority(int index, int prio);
|
||||||
|
|
||||||
// returns the priority for the piece at 'index'
|
// returns the priority for the piece at 'index'
|
||||||
int piece_priority(int index) const;
|
int piece_priority(int index) const;
|
||||||
|
@ -144,14 +144,15 @@ namespace libtorrent
|
|||||||
, int block_size = 16 * 1024
|
, int block_size = 16 * 1024
|
||||||
, storage_constructor_type sc = default_storage_constructor);
|
, storage_constructor_type sc = default_storage_constructor);
|
||||||
|
|
||||||
// TODO: deprecated, this is for backwards compatibility only
|
// ==== deprecated, this is for backwards compatibility only
|
||||||
|
// instead, use one of the other add_torrent overloads
|
||||||
torrent_handle add_torrent(
|
torrent_handle add_torrent(
|
||||||
entry const& e
|
entry const& e
|
||||||
, fs::path const& save_path
|
, fs::path const& save_path
|
||||||
, entry const& resume_data = entry()
|
, entry const& resume_data = entry()
|
||||||
, bool compact_mode = true
|
, bool compact_mode = true
|
||||||
, int block_size = 16 * 1024
|
, int block_size = 16 * 1024
|
||||||
, storage_constructor_type sc = default_storage_constructor)
|
, storage_constructor_type sc = default_storage_constructor) TORRENT_DEPRECATED
|
||||||
{
|
{
|
||||||
return add_torrent(torrent_info(e), save_path, resume_data
|
return add_torrent(torrent_info(e), save_path, resume_data
|
||||||
, compact_mode, block_size, sc);
|
, compact_mode, block_size, sc);
|
||||||
|
@ -296,13 +296,13 @@ namespace libtorrent
|
|||||||
|
|
||||||
// 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
|
||||||
void filter_piece(int index, bool filter) const;
|
void filter_piece(int index, bool filter) const TORRENT_DEPRECATED;
|
||||||
void filter_pieces(std::vector<bool> const& pieces) const;
|
void filter_pieces(std::vector<bool> const& pieces) const TORRENT_DEPRECATED;
|
||||||
bool is_piece_filtered(int index) const;
|
bool is_piece_filtered(int index) const TORRENT_DEPRECATED;
|
||||||
std::vector<bool> filtered_pieces() const;
|
std::vector<bool> filtered_pieces() const TORRENT_DEPRECATED;
|
||||||
// marks the file with the given index as filtered
|
// marks the file with the given index as filtered
|
||||||
// it will not be downloaded
|
// it will not be downloaded
|
||||||
void filter_files(std::vector<bool> const& files) const;
|
void filter_files(std::vector<bool> const& files) const TORRENT_DEPRECATED;
|
||||||
|
|
||||||
// ================ end deprecation ============
|
// ================ end deprecation ============
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <iosfwd>
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning(push, 1)
|
#pragma warning(push, 1)
|
||||||
@ -146,7 +147,8 @@ namespace libtorrent
|
|||||||
const std::string& name() const { assert(m_piece_length > 0); return m_name; }
|
const std::string& name() const { assert(m_piece_length > 0); return m_name; }
|
||||||
|
|
||||||
// ------- start deprecation -------
|
// ------- start deprecation -------
|
||||||
void print(std::ostream& os) const;
|
// this functionaily will be removed in a future version
|
||||||
|
void print(std::ostream& os) const TORRENT_DEPRECATED;
|
||||||
// ------- end deprecation -------
|
// ------- end deprecation -------
|
||||||
|
|
||||||
bool is_valid() const { return m_piece_length > 0; }
|
bool is_valid() const { return m_piece_length > 0; }
|
||||||
|
@ -966,7 +966,7 @@ namespace libtorrent
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void piece_picker::set_piece_priority(int index, int new_piece_priority)
|
bool piece_picker::set_piece_priority(int index, int new_piece_priority)
|
||||||
{
|
{
|
||||||
TORRENT_PIECE_PICKER_INVARIANT_CHECK;
|
TORRENT_PIECE_PICKER_INVARIANT_CHECK;
|
||||||
assert(new_piece_priority >= 0);
|
assert(new_piece_priority >= 0);
|
||||||
@ -977,16 +977,18 @@ namespace libtorrent
|
|||||||
piece_pos& p = m_piece_map[index];
|
piece_pos& p = m_piece_map[index];
|
||||||
|
|
||||||
// if the priority isn't changed, don't do anything
|
// if the priority isn't changed, don't do anything
|
||||||
if (new_piece_priority == int(p.piece_priority)) return;
|
if (new_piece_priority == int(p.piece_priority)) return false;
|
||||||
|
|
||||||
int prev_priority = p.priority(m_sequenced_download_threshold);
|
int prev_priority = p.priority(m_sequenced_download_threshold);
|
||||||
|
|
||||||
|
bool ret = false;
|
||||||
if (new_piece_priority == piece_pos::filter_priority
|
if (new_piece_priority == piece_pos::filter_priority
|
||||||
&& p.piece_priority != piece_pos::filter_priority)
|
&& p.piece_priority != piece_pos::filter_priority)
|
||||||
{
|
{
|
||||||
// the piece just got filtered
|
// the piece just got filtered
|
||||||
if (p.have()) ++m_num_have_filtered;
|
if (p.have()) ++m_num_have_filtered;
|
||||||
else ++m_num_filtered;
|
else ++m_num_filtered;
|
||||||
|
ret = true;
|
||||||
}
|
}
|
||||||
else if (new_piece_priority != piece_pos::filter_priority
|
else if (new_piece_priority != piece_pos::filter_priority
|
||||||
&& p.piece_priority == piece_pos::filter_priority)
|
&& p.piece_priority == piece_pos::filter_priority)
|
||||||
@ -994,6 +996,7 @@ namespace libtorrent
|
|||||||
// the piece just got unfiltered
|
// the piece just got unfiltered
|
||||||
if (p.have()) --m_num_have_filtered;
|
if (p.have()) --m_num_have_filtered;
|
||||||
else --m_num_filtered;
|
else --m_num_filtered;
|
||||||
|
ret = true;
|
||||||
}
|
}
|
||||||
assert(m_num_filtered >= 0);
|
assert(m_num_filtered >= 0);
|
||||||
assert(m_num_have_filtered >= 0);
|
assert(m_num_have_filtered >= 0);
|
||||||
@ -1001,7 +1004,7 @@ namespace libtorrent
|
|||||||
p.piece_priority = new_piece_priority;
|
p.piece_priority = new_piece_priority;
|
||||||
int new_priority = p.priority(m_sequenced_download_threshold);
|
int new_priority = p.priority(m_sequenced_download_threshold);
|
||||||
|
|
||||||
if (new_priority == prev_priority) return;
|
if (new_priority == prev_priority) return false;
|
||||||
|
|
||||||
if (prev_priority == 0)
|
if (prev_priority == 0)
|
||||||
{
|
{
|
||||||
@ -1011,6 +1014,7 @@ namespace libtorrent
|
|||||||
{
|
{
|
||||||
move(prev_priority, p.index);
|
move(prev_priority, p.index);
|
||||||
}
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int piece_picker::piece_priority(int index) const
|
int piece_picker::piece_priority(int index) const
|
||||||
|
@ -1119,8 +1119,8 @@ namespace libtorrent
|
|||||||
assert(index >= 0);
|
assert(index >= 0);
|
||||||
assert(index < m_torrent_file.num_pieces());
|
assert(index < m_torrent_file.num_pieces());
|
||||||
|
|
||||||
m_picker->set_piece_priority(index, priority);
|
bool filter_updated = m_picker->set_piece_priority(index, priority);
|
||||||
update_peer_interest();
|
if (filter_updated) update_peer_interest();
|
||||||
}
|
}
|
||||||
|
|
||||||
int torrent::piece_priority(int index) const
|
int torrent::piece_priority(int index) const
|
||||||
@ -1149,14 +1149,15 @@ namespace libtorrent
|
|||||||
assert(m_picker.get());
|
assert(m_picker.get());
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
bool filter_updated = false;
|
||||||
for (std::vector<int>::const_iterator i = pieces.begin()
|
for (std::vector<int>::const_iterator i = pieces.begin()
|
||||||
, end(pieces.end()); i != end; ++i, ++index)
|
, end(pieces.end()); i != end; ++i, ++index)
|
||||||
{
|
{
|
||||||
assert(*i >= 0);
|
assert(*i >= 0);
|
||||||
assert(*i <= 7);
|
assert(*i <= 7);
|
||||||
m_picker->set_piece_priority(index, *i);
|
filter_updated |= m_picker->set_piece_priority(index, *i);
|
||||||
}
|
}
|
||||||
update_peer_interest();
|
if (filter_updated) update_peer_interest();
|
||||||
}
|
}
|
||||||
|
|
||||||
void torrent::piece_priorities(std::vector<int>& pieces) const
|
void torrent::piece_priorities(std::vector<int>& pieces) const
|
||||||
|
Loading…
x
Reference in New Issue
Block a user