Docs for _start()

This commit is contained in:
Igor Katson 2024-12-06 12:14:34 +00:00
parent 38fec48879
commit 5f07872725
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
2 changed files with 8 additions and 3 deletions

View file

@ -1336,9 +1336,7 @@ impl Session {
}
pub async fn pause(&self, handle: &ManagedTorrentHandle) -> anyhow::Result<()> {
handle
.pause()
.map(|_| handle.locked.write().paused = true)?;
handle.pause()?;
self.try_update_persistence_metadata(handle).await;
Ok(())
}

View file

@ -274,6 +274,8 @@ impl ManagedTorrent {
g.state = ManagedTorrentState::Error(error)
}
/// peer_rx: the peer stream. If start_paused=false, must be set.
/// start_paused: if set, the torrent will initialize (check file integrity), but will not start
pub(crate) fn start(
self: &Arc<Self>,
peer_rx: Option<PeerStream>,
@ -389,6 +391,10 @@ impl ManagedTorrent {
}
}
if !start_paused && peer_rx.is_none() {
bail!("logic bug: start(start_paused=true, peer_rx=None) called. peer_rx must be set if starting the torrent")
}
let session = self
.shared
.session
@ -419,6 +425,7 @@ impl ManagedTorrent {
ManagedTorrentState::Live(live) => {
let paused = live.pause()?;
g.state = ManagedTorrentState::Paused(paused);
g.paused = true;
self.state_change_notify.notify_waiters();
Ok(())
}