forked from premiere/premiere-libtorrent
changed the definition of file_progress and deprecated the old function. Python bindings only exposes the new one
This commit is contained in:
parent
e49c015c92
commit
9bf25d1006
|
@ -74,7 +74,7 @@ namespace
|
||||||
|
|
||||||
list file_progress(torrent_handle& handle)
|
list file_progress(torrent_handle& handle)
|
||||||
{
|
{
|
||||||
std::vector<float> p;
|
std::vector<size_type> p;
|
||||||
|
|
||||||
{
|
{
|
||||||
allow_threading_guard guard;
|
allow_threading_guard guard;
|
||||||
|
@ -84,7 +84,7 @@ list file_progress(torrent_handle& handle)
|
||||||
|
|
||||||
list result;
|
list result;
|
||||||
|
|
||||||
for (std::vector<float>::iterator i(p.begin()), e(p.end()); i != e; ++i)
|
for (std::vector<size_type>::iterator i(p.begin()), e(p.end()); i != e; ++i)
|
||||||
result.append(*i);
|
result.append(*i);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -1517,7 +1517,7 @@ Its declaration looks like this::
|
||||||
torrent_handle();
|
torrent_handle();
|
||||||
|
|
||||||
torrent_status status();
|
torrent_status status();
|
||||||
void file_progress(std::vector<float>& fp);
|
void file_progress(std::vector<size_type>& fp);
|
||||||
void get_download_queue(std::vector<partial_piece_info>& queue) const;
|
void get_download_queue(std::vector<partial_piece_info>& queue) const;
|
||||||
void get_peer_info(std::vector<peer_info>& v) const;
|
void get_peer_info(std::vector<peer_info>& v) const;
|
||||||
torrent_info const& get_torrent_info() const;
|
torrent_info const& get_torrent_info() const;
|
||||||
|
@ -1659,12 +1659,13 @@ file_progress()
|
||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
void file_progress(std::vector<float>& fp);
|
void file_progress(std::vector<size_type>& fp);
|
||||||
|
|
||||||
This function fills in the supplied vector with the progress (a value in the
|
This function fills in the supplied vector with the the number of bytes downloaded
|
||||||
range [0, 1]) describing the download progress of each file in this torrent.
|
of each file in this torrent. The progress values are ordered the same as the files
|
||||||
The progress values are ordered the same as the files in the `torrent_info`_.
|
in the `torrent_info`_. This operation is not very cheap. Its complexity is *O(n + m*j)*.
|
||||||
This operation is not very cheap.
|
Where *n * is the number of files, *m * is the number of downloading pieces and *j *
|
||||||
|
is the number of blocks in a piece.
|
||||||
|
|
||||||
|
|
||||||
save_path()
|
save_path()
|
||||||
|
|
|
@ -222,6 +222,7 @@ namespace libtorrent
|
||||||
bool is_piece_filtered(int index) const;
|
bool is_piece_filtered(int index) const;
|
||||||
void filtered_pieces(std::vector<bool>& bitmask) const;
|
void filtered_pieces(std::vector<bool>& bitmask) const;
|
||||||
void filter_files(std::vector<bool> const& files);
|
void filter_files(std::vector<bool> const& files);
|
||||||
|
void file_progress(std::vector<float>& fp) const;
|
||||||
// ============ end deprecation =============
|
// ============ end deprecation =============
|
||||||
|
|
||||||
void piece_availability(std::vector<int>& avail) const;
|
void piece_availability(std::vector<int>& avail) const;
|
||||||
|
@ -235,7 +236,8 @@ namespace libtorrent
|
||||||
void prioritize_files(std::vector<int> const& files);
|
void prioritize_files(std::vector<int> const& files);
|
||||||
|
|
||||||
torrent_status status() const;
|
torrent_status status() const;
|
||||||
void file_progress(std::vector<float>& fp) const;
|
|
||||||
|
void file_progress(std::vector<size_type>& fp) const;
|
||||||
|
|
||||||
void use_interface(const char* net_interface);
|
void use_interface(const char* net_interface);
|
||||||
tcp::endpoint const& get_interface() const { return m_net_interface; }
|
tcp::endpoint const& get_interface() const { return m_net_interface; }
|
||||||
|
|
|
@ -322,7 +322,8 @@ namespace libtorrent
|
||||||
// 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);
|
void file_progress(std::vector<float>& progress) const TORRENT_DEPRECATED;
|
||||||
|
void file_progress(std::vector<size_type>& progress) const;
|
||||||
|
|
||||||
std::vector<announce_entry> const& trackers() const;
|
std::vector<announce_entry> const& trackers() const;
|
||||||
void replace_trackers(std::vector<announce_entry> const&) const;
|
void replace_trackers(std::vector<announce_entry> const&) const;
|
||||||
|
|
|
@ -4038,19 +4038,35 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
|
|
||||||
void torrent::file_progress(std::vector<float>& fp) const
|
void torrent::file_progress(std::vector<float>& fp) const
|
||||||
|
{
|
||||||
|
fp.clear();
|
||||||
|
fp.resize(m_torrent_file->num_files(), 1.f);
|
||||||
|
if (is_seed()) return;
|
||||||
|
|
||||||
|
std::vector<size_type> progress;
|
||||||
|
file_progress(progress);
|
||||||
|
for (int i = 0; i < m_torrent_file->num_files(); ++i)
|
||||||
|
{
|
||||||
|
file_entry const& f = m_torrent_file->file_at(i);
|
||||||
|
if (f.size == 0) fp[i] = 1.f;
|
||||||
|
else fp[i] = float(progress[i]) / f.size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void torrent::file_progress(std::vector<size_type>& fp) const
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(valid_metadata());
|
TORRENT_ASSERT(valid_metadata());
|
||||||
|
|
||||||
fp.clear();
|
fp.resize(m_torrent_file->num_files(), 0);
|
||||||
|
TORRENT_ASSERT(has_picker());
|
||||||
|
|
||||||
if (is_seed())
|
if (is_seed())
|
||||||
{
|
{
|
||||||
fp.resize(m_torrent_file->num_files(), 1.f);
|
for (int i = 0; i < m_torrent_file->num_files(); ++i)
|
||||||
|
fp[i] = m_torrent_file->files().at(i).size;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TORRENT_ASSERT(has_picker());
|
|
||||||
fp.resize(m_torrent_file->num_files(), 0.f);
|
|
||||||
|
|
||||||
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);
|
||||||
|
@ -4060,7 +4076,7 @@ namespace libtorrent
|
||||||
// 100% done all the time
|
// 100% done all the time
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
{
|
{
|
||||||
fp[i] = 1.f;
|
fp[i] = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4076,7 +4092,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
TORRENT_ASSERT(size == 0);
|
TORRENT_ASSERT(size == 0);
|
||||||
|
|
||||||
fp[i] = static_cast<float>(done) / m_torrent_file->files().at(i).size;
|
fp[i] = done;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<piece_picker::downloading_piece>& q
|
const std::vector<piece_picker::downloading_piece>& q
|
||||||
|
@ -4130,7 +4146,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(offset <= file->offset + file->size);
|
TORRENT_ASSERT(offset <= file->offset + file->size);
|
||||||
size_type slice = file->offset + file->size - offset;
|
size_type slice = file->offset + file->size - offset;
|
||||||
fp[file_index] += float(slice) / file->size;
|
fp[file_index] += slice;
|
||||||
offset += slice;
|
offset += slice;
|
||||||
block_size -= slice;
|
block_size -= slice;
|
||||||
++file;
|
++file;
|
||||||
|
@ -4141,7 +4157,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fp[file_index] += float(block_size) / file->size;
|
fp[file_index] += block_size;
|
||||||
offset += m_block_size;
|
offset += m_block_size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -326,7 +326,13 @@ namespace libtorrent
|
||||||
TORRENT_FORWARD(set_tracker_login(name, password));
|
TORRENT_FORWARD(set_tracker_login(name, password));
|
||||||
}
|
}
|
||||||
|
|
||||||
void torrent_handle::file_progress(std::vector<float>& progress)
|
void torrent_handle::file_progress(std::vector<float>& progress) const
|
||||||
|
{
|
||||||
|
INVARIANT_CHECK;
|
||||||
|
TORRENT_FORWARD(file_progress(progress));
|
||||||
|
}
|
||||||
|
|
||||||
|
void torrent_handle::file_progress(std::vector<size_type>& progress) const
|
||||||
{
|
{
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
TORRENT_FORWARD(file_progress(progress));
|
TORRENT_FORWARD(file_progress(progress));
|
||||||
|
|
Loading…
Reference in New Issue