@@ -22,16 +22,18 @@ pub enum DownloadManagerMessage {
2222pub struct DownloadManager {
2323 database : & ' static YTLocalDatabase ,
2424 cache_dir : PathBuf ,
25+ parallel_downloads : u16 ,
2526 handles : Mutex < Vec < JoinHandle < ( ) > > > ,
2627 download_list : Mutex < VecDeque < YoutubeMusicVideoRef > > ,
2728 in_download : Mutex < HashSet < String > > ,
2829}
2930
3031impl DownloadManager {
31- pub fn new ( cache_dir : PathBuf , database : & ' static YTLocalDatabase ) -> Self {
32+ pub fn new ( cache_dir : PathBuf , database : & ' static YTLocalDatabase , parallel_downloads : u16 ) -> Self {
3233 Self {
3334 database,
3435 cache_dir,
36+ parallel_downloads,
3537 handles : Mutex :: new ( Vec :: new ( ) ) ,
3638 download_list : Mutex :: new ( VecDeque :: new ( ) ) ,
3739 in_download : Mutex :: new ( HashSet :: new ( ) ) ,
@@ -78,7 +80,7 @@ impl DownloadManager {
7880 cancelation : impl Future < Output = ( ) > + Clone + Send + ' static ,
7981 sender : MessageHandler ,
8082 ) {
81- for _ in 0 ..DOWNLOADER_COUNT {
83+ for _ in 0 ..self . parallel_downloads {
8284 self . run_service_stream ( cancelation. clone ( ) , sender. clone ( ) ) ;
8385 }
8486 }
@@ -111,5 +113,3 @@ impl DownloadManager {
111113 list. extend ( to_add) ;
112114 }
113115}
114-
115- const DOWNLOADER_COUNT : usize = 4 ;
0 commit comments