Move session to shared state
This commit is contained in:
parent
451debedbb
commit
ad5f62b9b9
2 changed files with 3 additions and 2 deletions
|
|
@ -1138,6 +1138,7 @@ impl Session {
|
||||||
disk_write_queue: self.disk_write_tx.clone(),
|
disk_write_queue: self.disk_write_tx.clone(),
|
||||||
},
|
},
|
||||||
connector: self.connector.clone(),
|
connector: self.connector.clone(),
|
||||||
|
session: Arc::downgrade(self),
|
||||||
});
|
});
|
||||||
|
|
||||||
let initializing = Arc::new(TorrentStateInitializing::new(
|
let initializing = Arc::new(TorrentStateInitializing::new(
|
||||||
|
|
@ -1152,7 +1153,6 @@ impl Session {
|
||||||
}),
|
}),
|
||||||
state_change_notify: Notify::new(),
|
state_change_notify: Notify::new(),
|
||||||
shared: minfo,
|
shared: minfo,
|
||||||
session: Arc::downgrade(self),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
g.add_torrent(handle.clone(), id);
|
g.add_torrent(handle.clone(), id);
|
||||||
|
|
|
||||||
|
|
@ -119,11 +119,11 @@ pub struct ManagedTorrentShared {
|
||||||
pub(crate) options: ManagedTorrentOptions,
|
pub(crate) options: ManagedTorrentOptions,
|
||||||
pub(crate) connector: Arc<StreamConnector>,
|
pub(crate) connector: Arc<StreamConnector>,
|
||||||
pub(crate) storage_factory: BoxStorageFactory,
|
pub(crate) storage_factory: BoxStorageFactory,
|
||||||
|
pub(crate) session: Weak<Session>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ManagedTorrent {
|
pub struct ManagedTorrent {
|
||||||
pub shared: Arc<ManagedTorrentShared>,
|
pub shared: Arc<ManagedTorrentShared>,
|
||||||
pub(crate) session: Weak<Session>,
|
|
||||||
pub(crate) state_change_notify: Notify,
|
pub(crate) state_change_notify: Notify,
|
||||||
pub(crate) locked: RwLock<ManagedTorrentLocked>,
|
pub(crate) locked: RwLock<ManagedTorrentLocked>,
|
||||||
}
|
}
|
||||||
|
|
@ -213,6 +213,7 @@ impl ManagedTorrent {
|
||||||
start_paused: bool,
|
start_paused: bool,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
let session = self
|
let session = self
|
||||||
|
.shared
|
||||||
.session
|
.session
|
||||||
.upgrade()
|
.upgrade()
|
||||||
.context("session is dead, cannot start torrent")?;
|
.context("session is dead, cannot start torrent")?;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue