Session persistence

This commit is contained in:
Igor Katson 2023-11-25 02:36:19 +00:00
parent e467787c38
commit bec5e1be7f
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
7 changed files with 204 additions and 51 deletions

View file

@ -85,7 +85,7 @@ pub struct ManagedTorrentInfo {
pub struct ManagedTorrent {
pub info: Arc<ManagedTorrentInfo>,
only_files: Option<Vec<usize>>,
pub(crate) only_files: Option<Vec<usize>>,
locked: RwLock<ManagedTorrentLocked>,
}
@ -138,6 +138,7 @@ impl ManagedTorrent {
self: &Arc<Self>,
initial_peers: Vec<SocketAddr>,
peer_rx: Option<impl StreamExt<Item = SocketAddr> + Unpin + Send + Sync + 'static>,
start_paused: bool,
) -> anyhow::Result<()> {
let mut g = self.locked.write();
@ -185,6 +186,11 @@ impl ManagedTorrent {
return Ok(());
}
if start_paused {
g.state = ManagedTorrentState::Paused(paused);
return Ok(());
}
let live = TorrentStateLive::new(paused);
g.state = ManagedTorrentState::Live(live.clone());