Remove unused field

This commit is contained in:
Igor Katson 2024-02-26 08:55:53 +00:00
parent 3a7207265f
commit 51dba8ab67
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
2 changed files with 2 additions and 12 deletions

View file

@ -972,7 +972,6 @@ impl Session {
builder builder
.overwrite(opts.overwrite) .overwrite(opts.overwrite)
.spawner(self.spawner) .spawner(self.spawner)
.cancellation_token(cancellation_token.clone())
.trackers(trackers) .trackers(trackers)
.peer_id(self.peer_id); .peer_id(self.peer_id);
@ -1101,7 +1100,7 @@ impl Session {
} }
pub fn unpause(&self, handle: &ManagedTorrentHandle) -> anyhow::Result<()> { 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( let peer_rx = self.make_peer_rx(
handle.info_hash(), handle.info_hash(),
handle.info().trackers.clone().into_iter().collect(), handle.info().trackers.clone().into_iter().collect(),

View file

@ -91,7 +91,6 @@ pub struct ManagedTorrentInfo {
pub struct ManagedTorrent { pub struct ManagedTorrent {
pub info: Arc<ManagedTorrentInfo>, pub info: Arc<ManagedTorrentInfo>,
pub cancellation_token: CancellationToken,
pub(crate) only_files: Option<Vec<usize>>, pub(crate) only_files: Option<Vec<usize>>,
locked: RwLock<ManagedTorrentLocked>, locked: RwLock<ManagedTorrentLocked>,
} }
@ -428,7 +427,6 @@ pub struct ManagedTorrentBuilder {
peer_id: Option<Id20>, peer_id: Option<Id20>,
overwrite: bool, overwrite: bool,
spawner: Option<BlockingSpawner>, spawner: Option<BlockingSpawner>,
cancellation_token: Option<CancellationToken>,
} }
impl ManagedTorrentBuilder { impl ManagedTorrentBuilder {
@ -449,15 +447,9 @@ impl ManagedTorrentBuilder {
trackers: Default::default(), trackers: Default::default(),
peer_id: None, peer_id: None,
overwrite: false, 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<usize>) -> &mut Self { pub fn only_files(&mut self, only_files: Vec<usize>) -> &mut Self {
self.only_files = Some(only_files); self.only_files = Some(only_files);
self self
@ -498,7 +490,7 @@ impl ManagedTorrentBuilder {
self self
} }
pub(crate) fn build(mut self, span: tracing::Span) -> anyhow::Result<ManagedTorrentHandle> { pub(crate) fn build(self, span: tracing::Span) -> anyhow::Result<ManagedTorrentHandle> {
let lengths = Lengths::from_torrent(&self.info)?; let lengths = Lengths::from_torrent(&self.info)?;
let info = Arc::new(ManagedTorrentInfo { let info = Arc::new(ManagedTorrentInfo {
span, span,
@ -525,7 +517,6 @@ impl ManagedTorrentBuilder {
locked: RwLock::new(ManagedTorrentLocked { locked: RwLock::new(ManagedTorrentLocked {
state: ManagedTorrentState::Initializing(initializing), state: ManagedTorrentState::Initializing(initializing),
}), }),
cancellation_token: self.cancellation_token.take().unwrap_or_default(),
info, info,
})) }))
} }