use a proper optional value instead of a sentiel value for bytes_left()
This commit is contained in:
parent
f262bbdcea
commit
30a7b52855
|
@ -483,7 +483,7 @@ namespace libtorrent {
|
||||||
std::string name() const;
|
std::string name() const;
|
||||||
|
|
||||||
stat statistics() const { return m_stat; }
|
stat statistics() const { return m_stat; }
|
||||||
std::int64_t bytes_left() const;
|
boost::optional<std::int64_t> bytes_left() const;
|
||||||
int block_bytes_wanted(piece_block const& p) const;
|
int block_bytes_wanted(piece_block const& p) const;
|
||||||
void bytes_done(torrent_status& st, bool accurate) const;
|
void bytes_done(torrent_status& st, bool accurate) const;
|
||||||
std::int64_t quantized_bytes_done() const;
|
std::int64_t quantized_bytes_done() const;
|
||||||
|
|
|
@ -2724,8 +2724,7 @@ namespace libtorrent {
|
||||||
req.downloaded = m_stat.total_payload_download() - m_total_failed_bytes;
|
req.downloaded = m_stat.total_payload_download() - m_total_failed_bytes;
|
||||||
req.uploaded = m_stat.total_payload_upload();
|
req.uploaded = m_stat.total_payload_upload();
|
||||||
req.corrupt = m_total_failed_bytes;
|
req.corrupt = m_total_failed_bytes;
|
||||||
req.left = bytes_left();
|
req.left = value_or(bytes_left(), 16*1024);
|
||||||
if (req.left == -1) req.left = 16*1024;
|
|
||||||
#ifdef TORRENT_USE_OPENSSL
|
#ifdef TORRENT_USE_OPENSSL
|
||||||
// if this torrent contains an SSL certificate, make sure
|
// if this torrent contains an SSL certificate, make sure
|
||||||
// any SSL tracker presents a certificate signed by it
|
// any SSL tracker presents a certificate signed by it
|
||||||
|
@ -3467,11 +3466,11 @@ namespace libtorrent {
|
||||||
}
|
}
|
||||||
catch (...) { handle_exception(); }
|
catch (...) { handle_exception(); }
|
||||||
|
|
||||||
std::int64_t torrent::bytes_left() const
|
boost::optional<std::int64_t> torrent::bytes_left() const
|
||||||
{
|
{
|
||||||
// if we don't have the metadata yet, we
|
// if we don't have the metadata yet, we
|
||||||
// cannot tell how big the torrent is.
|
// cannot tell how big the torrent is.
|
||||||
if (!valid_metadata()) return -1;
|
if (!valid_metadata()) return {};
|
||||||
return m_torrent_file->total_size()
|
return m_torrent_file->total_size()
|
||||||
- quantized_bytes_done();
|
- quantized_bytes_done();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue