Skip to content

Commit

Permalink
Move on_piece_completed() to a more appropriate place
Browse files Browse the repository at this point in the history
  • Loading branch information
ikatson committed Sep 13, 2024
1 parent 88c8e51 commit 8974a01
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 0 additions & 2 deletions crates/librqbit/src/file_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions crates/librqbit/src/torrent_state/live/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()?;
Expand Down

0 comments on commit 8974a01

Please sign in to comment.