Docs for _start()
This commit is contained in:
parent
38fec48879
commit
5f07872725
2 changed files with 8 additions and 3 deletions
|
|
@ -1336,9 +1336,7 @@ impl Session {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn pause(&self, handle: &ManagedTorrentHandle) -> anyhow::Result<()> {
|
pub async fn pause(&self, handle: &ManagedTorrentHandle) -> anyhow::Result<()> {
|
||||||
handle
|
handle.pause()?;
|
||||||
.pause()
|
|
||||||
.map(|_| handle.locked.write().paused = true)?;
|
|
||||||
self.try_update_persistence_metadata(handle).await;
|
self.try_update_persistence_metadata(handle).await;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -274,6 +274,8 @@ impl ManagedTorrent {
|
||||||
g.state = ManagedTorrentState::Error(error)
|
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(
|
pub(crate) fn start(
|
||||||
self: &Arc<Self>,
|
self: &Arc<Self>,
|
||||||
peer_rx: Option<PeerStream>,
|
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
|
let session = self
|
||||||
.shared
|
.shared
|
||||||
.session
|
.session
|
||||||
|
|
@ -419,6 +425,7 @@ impl ManagedTorrent {
|
||||||
ManagedTorrentState::Live(live) => {
|
ManagedTorrentState::Live(live) => {
|
||||||
let paused = live.pause()?;
|
let paused = live.pause()?;
|
||||||
g.state = ManagedTorrentState::Paused(paused);
|
g.state = ManagedTorrentState::Paused(paused);
|
||||||
|
g.paused = true;
|
||||||
self.state_change_notify.notify_waiters();
|
self.state_change_notify.notify_waiters();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue