Move some fields into ManagedTorrentInfo

This commit is contained in:
Igor Katson 2024-08-21 16:06:16 +01:00
parent ad7b59ea3c
commit b4512e4809
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
3 changed files with 9 additions and 10 deletions

View file

@ -100,6 +100,7 @@ pub(crate) struct ManagedTorrentOptions {
}
pub struct ManagedTorrentInfo {
pub id: TorrentId,
pub info: TorrentMetaV1Info<ByteBufOwned>,
pub torrent_bytes: Bytes,
pub info_bytes: Bytes,
@ -112,14 +113,11 @@ pub struct ManagedTorrentInfo {
pub span: tracing::Span,
pub(crate) options: ManagedTorrentOptions,
pub(crate) connector: Arc<StreamConnector>,
pub(crate) storage_factory: BoxStorageFactory,
}
pub struct ManagedTorrent {
pub id: TorrentId,
// TODO: merge ManagedTorrent and ManagedTorrentInfo
pub info: Arc<ManagedTorrentInfo>,
pub(crate) storage_factory: BoxStorageFactory,
pub(crate) session: Weak<Session>,
pub(crate) state_change_notify: Notify,
pub(crate) locked: RwLock<ManagedTorrentLocked>,
@ -127,7 +125,7 @@ pub struct ManagedTorrent {
impl ManagedTorrent {
pub fn id(&self) -> TorrentId {
self.id
self.info.id
}
pub fn info(&self) -> &ManagedTorrentInfo {
@ -369,7 +367,7 @@ impl ManagedTorrent {
let initializing = Arc::new(TorrentStateInitializing::new(
self.info.clone(),
g.only_files.clone(),
self.storage_factory.create_and_init(self.info())?,
self.info.storage_factory.create_and_init(self.info())?,
));
g.state = ManagedTorrentState::Initializing(initializing.clone());
drop(g);