diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index c1fafc330..22c64dad7 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -1557,6 +1557,9 @@ namespace libtorrent m_have_piece.set_bit(index); ++m_num_pieces; + // if the peer is downloading stuff, it must have metadata + m_has_metadata = true; + // only update the piece_picker if // we have the metadata and if // we're not a seed (in which case @@ -1576,9 +1579,6 @@ namespace libtorrent m_remote_bytes_dled += t->torrent_file().piece_size(index); } - // if the peer is downloading stuff, it must have metadata - m_has_metadata = true; - // it's important to not disconnect before we have // updated the piece picker, otherwise we will incorrectly // decrement the piece count without first incrementing it @@ -2649,6 +2649,9 @@ namespace libtorrent m_have_piece.clear_all(); m_num_pieces = 0; + // if the peer is ready to download stuff, it must have metadata + m_has_metadata = true; + // we're never interested in a peer that doesn't have anything send_not_interested(); diff --git a/src/ut_metadata.cpp b/src/ut_metadata.cpp index f9cb7c202..6210494c8 100644 --- a/src/ut_metadata.cpp +++ b/src/ut_metadata.cpp @@ -424,7 +424,7 @@ namespace libtorrent { namespace bool has_metadata() const { - return time_now() > m_request_limit; + return m_pc.has_metadata() || (time_now() > m_request_limit); } void failed_hash_check(ptime const& now)