From 51dba8ab67195304a0389fdfc180a3147fbcca94 Mon Sep 17 00:00:00 2001 From: Igor Katson Date: Mon, 26 Feb 2024 08:55:53 +0000 Subject: [PATCH] Remove unused field --- crates/librqbit/src/session.rs | 3 +-- crates/librqbit/src/torrent_state/mod.rs | 11 +---------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/crates/librqbit/src/session.rs b/crates/librqbit/src/session.rs index f38c85d..3d81b66 100644 --- a/crates/librqbit/src/session.rs +++ b/crates/librqbit/src/session.rs @@ -972,7 +972,6 @@ impl Session { builder .overwrite(opts.overwrite) .spawner(self.spawner) - .cancellation_token(cancellation_token.clone()) .trackers(trackers) .peer_id(self.peer_id); @@ -1101,7 +1100,7 @@ impl Session { } pub fn unpause(&self, handle: &ManagedTorrentHandle) -> anyhow::Result<()> { - let token = handle.cancellation_token.child_token(); + let token = self.cancellation_token.child_token(); let peer_rx = self.make_peer_rx( handle.info_hash(), handle.info().trackers.clone().into_iter().collect(), diff --git a/crates/librqbit/src/torrent_state/mod.rs b/crates/librqbit/src/torrent_state/mod.rs index d8267fa..90bfd8e 100644 --- a/crates/librqbit/src/torrent_state/mod.rs +++ b/crates/librqbit/src/torrent_state/mod.rs @@ -91,7 +91,6 @@ pub struct ManagedTorrentInfo { pub struct ManagedTorrent { pub info: Arc, - pub cancellation_token: CancellationToken, pub(crate) only_files: Option>, locked: RwLock, } @@ -428,7 +427,6 @@ pub struct ManagedTorrentBuilder { peer_id: Option, overwrite: bool, spawner: Option, - cancellation_token: Option, } impl ManagedTorrentBuilder { @@ -449,15 +447,9 @@ impl ManagedTorrentBuilder { trackers: Default::default(), peer_id: None, overwrite: false, - cancellation_token: None, } } - pub fn cancellation_token(&mut self, token: CancellationToken) -> &mut Self { - self.cancellation_token = Some(token); - self - } - pub fn only_files(&mut self, only_files: Vec) -> &mut Self { self.only_files = Some(only_files); self @@ -498,7 +490,7 @@ impl ManagedTorrentBuilder { self } - pub(crate) fn build(mut self, span: tracing::Span) -> anyhow::Result { + pub(crate) fn build(self, span: tracing::Span) -> anyhow::Result { let lengths = Lengths::from_torrent(&self.info)?; let info = Arc::new(ManagedTorrentInfo { span, @@ -525,7 +517,6 @@ impl ManagedTorrentBuilder { locked: RwLock::new(ManagedTorrentLocked { state: ManagedTorrentState::Initializing(initializing), }), - cancellation_token: self.cancellation_token.take().unwrap_or_default(), info, })) }