diff --git a/crates/librqbit/src/session.rs b/crates/librqbit/src/session.rs index 377a744..60491eb 100644 --- a/crates/librqbit/src/session.rs +++ b/crates/librqbit/src/session.rs @@ -1138,6 +1138,7 @@ impl Session { disk_write_queue: self.disk_write_tx.clone(), }, connector: self.connector.clone(), + session: Arc::downgrade(self), }); let initializing = Arc::new(TorrentStateInitializing::new( @@ -1152,7 +1153,6 @@ impl Session { }), state_change_notify: Notify::new(), shared: minfo, - session: Arc::downgrade(self), }); g.add_torrent(handle.clone(), id); diff --git a/crates/librqbit/src/torrent_state/mod.rs b/crates/librqbit/src/torrent_state/mod.rs index 3de4956..d602f5b 100644 --- a/crates/librqbit/src/torrent_state/mod.rs +++ b/crates/librqbit/src/torrent_state/mod.rs @@ -119,11 +119,11 @@ pub struct ManagedTorrentShared { pub(crate) options: ManagedTorrentOptions, pub(crate) connector: Arc, pub(crate) storage_factory: BoxStorageFactory, + pub(crate) session: Weak, } pub struct ManagedTorrent { pub shared: Arc, - pub(crate) session: Weak, pub(crate) state_change_notify: Notify, pub(crate) locked: RwLock, } @@ -213,6 +213,7 @@ impl ManagedTorrent { start_paused: bool, ) -> anyhow::Result<()> { let session = self + .shared .session .upgrade() .context("session is dead, cannot start torrent")?;