@@ -453,7 +453,6 @@ use std::net::IpAddr;
453453use std:: sync:: Arc ;
454454
455455use bittorrent_primitives:: info_hash:: InfoHash ;
456- use torrent:: manager:: TorrentsManager ;
457456use torrent:: repository:: in_memory:: InMemoryTorrentRepository ;
458457use torrent:: repository:: persisted:: DatabasePersistentTorrentRepository ;
459458use torrust_tracker_configuration:: { AnnouncePolicy , Core , TORRENT_PEERS_LIMIT } ;
@@ -483,9 +482,6 @@ pub struct Tracker {
483482
484483 /// The persistent torrents repository.
485484 db_torrent_repository : Arc < DatabasePersistentTorrentRepository > ,
486-
487- /// The service to run torrents tasks.
488- torrents_manager : Arc < TorrentsManager > ,
489485}
490486
491487/// How many peers the peer announcing wants in the announce response.
@@ -541,14 +537,12 @@ impl Tracker {
541537 whitelist_authorization : & Arc < whitelist:: authorization:: Authorization > ,
542538 in_memory_torrent_repository : & Arc < InMemoryTorrentRepository > ,
543539 db_torrent_repository : & Arc < DatabasePersistentTorrentRepository > ,
544- torrents_manager : & Arc < TorrentsManager > ,
545540 ) -> Result < Tracker , databases:: error:: Error > {
546541 Ok ( Tracker {
547542 config : config. clone ( ) ,
548543 whitelist_authorization : whitelist_authorization. clone ( ) ,
549544 in_memory_torrent_repository : in_memory_torrent_repository. clone ( ) ,
550545 db_torrent_repository : db_torrent_repository. clone ( ) ,
551- torrents_manager : torrents_manager. clone ( ) ,
552546 } )
553547 }
554548
@@ -724,13 +718,6 @@ impl Tracker {
724718 pub fn get_torrents_metrics ( & self ) -> TorrentsMetrics {
725719 self . in_memory_torrent_repository . get_torrents_metrics ( )
726720 }
727-
728- /// Remove inactive peers and (optionally) peerless torrents.
729- ///
730- /// # Context: Tracker
731- pub fn cleanup_torrents ( & self ) {
732- self . torrents_manager . cleanup_torrents ( ) ;
733- }
734721}
735722
736723#[ must_use]
@@ -761,6 +748,7 @@ mod tests {
761748 use crate :: app_test:: initialize_tracker_dependencies;
762749 use crate :: core:: peer:: Peer ;
763750 use crate :: core:: services:: { initialize_tracker, initialize_whitelist_manager} ;
751+ use crate :: core:: torrent:: manager:: TorrentsManager ;
764752 use crate :: core:: whitelist:: manager:: WhiteListManager ;
765753 use crate :: core:: { whitelist, TorrentsMetrics , Tracker } ;
766754
@@ -774,15 +762,14 @@ mod tests {
774762 _authentication_service,
775763 in_memory_torrent_repository,
776764 db_torrent_repository,
777- torrents_manager ,
765+ _torrents_manager ,
778766 ) = initialize_tracker_dependencies ( & config) ;
779767
780768 initialize_tracker (
781769 & config,
782770 & whitelist_authorization,
783771 & in_memory_torrent_repository,
784772 & db_torrent_repository,
785- & torrents_manager,
786773 )
787774 }
788775
@@ -796,7 +783,7 @@ mod tests {
796783 _authentication_service,
797784 in_memory_torrent_repository,
798785 db_torrent_repository,
799- torrents_manager ,
786+ _torrents_manager ,
800787 ) = initialize_tracker_dependencies ( & config) ;
801788
802789 let whitelist_manager = initialize_whitelist_manager ( database. clone ( ) , in_memory_whitelist. clone ( ) ) ;
@@ -806,13 +793,12 @@ mod tests {
806793 & whitelist_authorization,
807794 & in_memory_torrent_repository,
808795 & db_torrent_repository,
809- & torrents_manager,
810796 ) ;
811797
812798 ( tracker, whitelist_authorization, whitelist_manager)
813799 }
814800
815- pub fn tracker_persisting_torrents_in_database ( ) -> Tracker {
801+ pub fn tracker_persisting_torrents_in_database ( ) -> ( Tracker , Arc < TorrentsManager > ) {
816802 let mut config = configuration:: ephemeral_listed ( ) ;
817803 config. core . tracker_policy . persistent_torrent_completed_stat = true ;
818804
@@ -826,13 +812,14 @@ mod tests {
826812 torrents_manager,
827813 ) = initialize_tracker_dependencies ( & config) ;
828814
829- initialize_tracker (
815+ let tracker = initialize_tracker (
830816 & config,
831817 & whitelist_authorization,
832818 & in_memory_torrent_repository,
833819 & db_torrent_repository,
834- & torrents_manager,
835- )
820+ ) ;
821+
822+ ( tracker, torrents_manager)
836823 }
837824
838825 fn sample_info_hash ( ) -> InfoHash {
@@ -1492,7 +1479,7 @@ mod tests {
14921479
14931480 #[ tokio:: test]
14941481 async fn it_should_persist_the_number_of_completed_peers_for_all_torrents_into_the_database ( ) {
1495- let tracker = tracker_persisting_torrents_in_database ( ) ;
1482+ let ( tracker, torrents_manager ) = tracker_persisting_torrents_in_database ( ) ;
14961483
14971484 let info_hash = sample_info_hash ( ) ;
14981485
@@ -1509,7 +1496,7 @@ mod tests {
15091496 // Remove the newly updated torrent from memory
15101497 let _unused = tracker. in_memory_torrent_repository . remove ( & info_hash) ;
15111498
1512- tracker . torrents_manager . load_torrents_from_database ( ) . unwrap ( ) ;
1499+ torrents_manager. load_torrents_from_database ( ) . unwrap ( ) ;
15131500
15141501 let torrent_entry = tracker
15151502 . in_memory_torrent_repository
0 commit comments