Fix a bug when remarking already have pieces broken

This commit is contained in:
Igor Katson 2024-01-02 18:52:00 +00:00
parent 0ff63d8a24
commit b808382169
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
2 changed files with 14 additions and 10 deletions

View file

@ -748,7 +748,7 @@ impl TorrentStateLive {
.take()
.context("bug: pausing already paused torrent")?;
for piece_id in g.inflight_pieces.keys().copied() {
chunk_tracker.mark_piece_broken(piece_id);
chunk_tracker.mark_piece_broken_if_not_have(piece_id);
}
let have_bytes = chunk_tracker.calc_have_bytes();
let needed_bytes = chunk_tracker.calc_needed_bytes();
@ -1494,7 +1494,7 @@ impl PeerHandler {
self.state
.lock_write("mark_piece_broken")
.get_chunks_mut()?
.mark_piece_broken(chunk_info.piece_index);
.mark_piece_broken_if_not_have(chunk_info.piece_index);
}
};
Ok::<_, anyhow::Error>(())