diff --git a/hammond-data/src/feed.rs b/hammond-data/src/feed.rs index 56faf97..b571723 100644 --- a/hammond-data/src/feed.rs +++ b/hammond-data/src/feed.rs @@ -48,15 +48,16 @@ impl Feed { // The synchronous version where there was a db.lock() before the episodes.iter() // is actually faster. fn index_channel_items(&self, db: &Database, pd: &Podcast) -> Result<()> { - let it = self.channel.items(); - let episodes: Vec<_> = it.par_iter() - .map(|x| parser::new_episode(x, *pd.id())) + let items = self.channel.items(); + let episodes: Vec<_> = items + .into_par_iter() + .map(|item| parser::new_episode(item, *pd.id())) .collect(); - episodes.into_par_iter().for_each(|x| { - let e = x.index(&Arc::clone(db)); + episodes.into_par_iter().for_each(|ep| { + let e = ep.index(&Arc::clone(db)); if let Err(err) = e { - error!("Failed to index episode: {:?}.", x); + error!("Failed to index episode: {:?}.", ep); error!("Error msg: {}", err); }; }); @@ -72,9 +73,9 @@ pub fn index_all(db: &Database) -> Result<()> { Ok(()) } -pub fn index(db: &Database, f: &mut [Feed]) { - f.into_par_iter().for_each(|x| { - let e = x.index(&Arc::clone(db)); +pub fn index(db: &Database, feeds: &mut [Feed]) { + feeds.into_par_iter().for_each(|f| { + let e = f.index(&Arc::clone(db)); if e.is_err() { error!("Error While trying to update the database."); error!("Error msg: {}", e.unwrap_err()); diff --git a/hammond-data/src/utils.rs b/hammond-data/src/utils.rs index bf81cbd..43fea18 100644 --- a/hammond-data/src/utils.rs +++ b/hammond-data/src/utils.rs @@ -12,12 +12,12 @@ use std::sync::Arc; // TODO: Write unit test. fn download_checker(db: &Database) -> Result<()> { - let mut episodes = { + let episodes = { let tempdb = db.lock().unwrap(); dbqueries::get_downloaded_episodes(&tempdb)? }; - episodes.par_iter_mut().for_each(|ep| { + episodes.into_par_iter().for_each(|mut ep| { if !Path::new(ep.local_uri().unwrap()).exists() { ep.set_local_uri(None); let res = ep.save(&Arc::clone(db)); @@ -33,13 +33,13 @@ fn download_checker(db: &Database) -> Result<()> { // TODO: Write unit test. fn played_cleaner(db: &Database) -> Result<()> { - let mut episodes = { + let episodes = { let tempdb = db.lock().unwrap(); dbqueries::get_played_episodes(&tempdb)? }; let now_utc = Utc::now().timestamp() as i32; - episodes.par_iter_mut().for_each(|mut ep| { + episodes.into_par_iter().for_each(|mut ep| { if ep.local_uri().is_some() && ep.played().is_some() { let played = ep.played().unwrap(); // TODO: expose a config and a user set option. diff --git a/hammond-gtk/src/widgets/episode.rs b/hammond-gtk/src/widgets/episode.rs index 432d1a3..385a470 100644 --- a/hammond-gtk/src/widgets/episode.rs +++ b/hammond-gtk/src/widgets/episode.rs @@ -202,12 +202,12 @@ fn receive() -> glib::Continue { pub fn episodes_listbox(db: &Database, pd: &Podcast) -> Result { let conn = db.lock().unwrap(); - let mut episodes = dbqueries::get_pd_episodes(&conn, pd)?; + let episodes = dbqueries::get_pd_episodes(&conn, pd)?; drop(conn); let list = gtk::ListBox::new(); - episodes.iter_mut().for_each(|ep| { - let w = epidose_widget(db, ep, pd.title()); + episodes.into_iter().for_each(|mut ep| { + let w = epidose_widget(db, &mut ep, pd.title()); list.add(&w) });