Move on_piece_completed() to a more appropriate place

This commit is contained in:
Igor Katson 2024-09-13 09:25:52 +01:00
parent 88c8e51ab8
commit 8974a013ce
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
2 changed files with 3 additions and 2 deletions

View file

@ -208,8 +208,6 @@ impl<'a> FileOps<'a> {
format!("error reading {to_read_in_file} bytes, file_id: {file_idx} (\"{name:?}\")")
})?;
self.files.on_piece_completed(piece_index)?;
piece_remaining_bytes -= to_read_in_file;
if piece_remaining_bytes == 0 {

View file

@ -719,6 +719,9 @@ impl TorrentStateLive {
}
fn on_piece_completed(&self, id: ValidPieceIndex) -> anyhow::Result<()> {
if let Err(e) = self.files.on_piece_completed(id) {
debug!(?id, "file storage errored in on_piece_completed(): {e:#}");
}
let mut g = self.lock_write("on_piece_completed");
let locked = &mut **g;
let chunks = locked.get_chunks_mut()?;