Skip to content

Commit

Permalink
feat: remove on_piece_completed from TorrentStorage trait
Browse files Browse the repository at this point in the history
  • Loading branch information
LIAUD Corentin committed Oct 5, 2024
1 parent 0734368 commit 8ae2900
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 13 deletions.
10 changes: 0 additions & 10 deletions crates/librqbit/src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,6 @@ pub trait TorrentStorage: Send + Sync {
/// Replace the current storage with a dummy, and return a new one that should be used instead.
/// This is used to make the underlying object useless when e.g. pausing the torrent.
fn take(&self) -> anyhow::Result<Box<dyn TorrentStorage>>;

/// Callback called every time a piece has completed and has been validated.
/// Default implementation does nothing, but can be override in trait implementations.
fn on_piece_completed(&self, _piece_index: ValidPieceIndex) -> anyhow::Result<()> {
Ok(())
}
}

impl<U: TorrentStorage + ?Sized> TorrentStorage for Box<U> {
Expand Down Expand Up @@ -138,8 +132,4 @@ impl<U: TorrentStorage + ?Sized> TorrentStorage for Box<U> {
fn init(&mut self, meta: &ManagedTorrentShared) -> anyhow::Result<()> {
(**self).init(meta)
}

fn on_piece_completed(&self, piece_id: ValidPieceIndex) -> anyhow::Result<()> {
(**self).on_piece_completed(piece_id)
}
}
3 changes: 0 additions & 3 deletions crates/librqbit/src/torrent_state/live/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -731,9 +731,6 @@ impl TorrentStateLive {
}

fn on_piece_completed(&self, id: ValidPieceIndex) -> anyhow::Result<()> {
if let Err(e) = self.files.as_storage().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 8ae2900

Please sign in to comment.