1/n Add pause/start actions

This commit is contained in:
Igor Katson 2023-11-24 14:19:39 +00:00
parent afbf2a76b9
commit 0c4844f534
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
4 changed files with 50 additions and 12 deletions

View file

@ -224,8 +224,7 @@ impl Session {
.dht
.as_ref()
.context("magnet links without DHT are not supported")?
.get_peers(info_hash)
.await?;
.get_peers(info_hash)?;
let trackers = trackers
.into_iter()
@ -274,7 +273,7 @@ impl Session {
let dht_rx = match self.dht.as_ref() {
Some(dht) => {
debug!("reading peers for {:?} from DHT", torrent.info_hash);
Some(dht.get_peers(torrent.info_hash).await?)
Some(dht.get_peers(torrent.info_hash)?)
}
None => None,
};
@ -430,7 +429,13 @@ impl Session {
self.locked.read().torrents.get(id).cloned()
}
pub fn restart(&self, id: usize) -> anyhow::Result<()> {
todo!()
pub fn unpause(&self, handle: &ManagedTorrentHandle) -> anyhow::Result<()> {
let peer_rx = self
.dht
.as_ref()
.map(|dht| dht.get_peers(handle.info_hash()))
.transpose()?;
handle.start(Default::default(), peer_rx);
return Ok(());
}
}