From b108b1d0444494b17e5f1be3994669f59ddbcaf1 Mon Sep 17 00:00:00 2001 From: arvidn Date: Thu, 28 Nov 2019 14:52:40 +0100 Subject: [PATCH] clarify documentation around torrent_handle::have_piece() and piece_finished_alert --- include/libtorrent/alert_types.hpp | 3 +++ include/libtorrent/torrent_handle.hpp | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/include/libtorrent/alert_types.hpp b/include/libtorrent/alert_types.hpp index 753eb48ea..29ac853ab 100644 --- a/include/libtorrent/alert_types.hpp +++ b/include/libtorrent/alert_types.hpp @@ -868,6 +868,9 @@ TORRENT_VERSION_NAMESPACE_2 // this alert is posted every time a piece completes downloading // and passes the hash check. This alert derives from torrent_alert // which contains the torrent_handle to the torrent the piece belongs to. + // Note that being downloaded and passing the hash check may happen before + // the piece is also fully flushed to disk. So torrent_handle::have_piece() + // may still return false struct TORRENT_EXPORT piece_finished_alert final : torrent_alert { // internal diff --git a/include/libtorrent/torrent_handle.hpp b/include/libtorrent/torrent_handle.hpp index 9af651cbb..92afcf7a3 100644 --- a/include/libtorrent/torrent_handle.hpp +++ b/include/libtorrent/torrent_handle.hpp @@ -287,8 +287,8 @@ namespace aux { // guaranteed to finish in the same order as you initiated them. void read_piece(piece_index_t piece) const; - // Returns true if this piece has been completely downloaded, and false - // otherwise. + // Returns true if this piece has been completely downloaded and written + // to disk, and false otherwise. bool have_piece(piece_index_t piece) const; #if TORRENT_ABI_VERSION == 1