diff --git a/hammond-data/src/index_feed.rs b/hammond-data/src/index_feed.rs index 103a96e..64589f1 100644 --- a/hammond-data/src/index_feed.rs +++ b/hammond-data/src/index_feed.rs @@ -119,8 +119,7 @@ fn complete_index( parent: &Source, ) -> Result<()> { let pd = { - let db = connection.clone(); - let db = db.lock().unwrap(); + let db = connection.lock().unwrap(); index_channel(&db, chan, parent)? }; @@ -140,8 +139,7 @@ fn index_channel_items(connection: &Arc>, it: &[rss::Ite it.par_iter() .map(|x| feedparser::parse_episode(x, pd.id())) .for_each(|x| { - let db = connection.clone(); - let db = db.lock().unwrap(); + let db = connection.lock().unwrap(); let e = index_episode(&db, &x); if let Err(err) = e { error!("Failed to index episode: {:?}.", x); diff --git a/hammond-downloader/src/downloader.rs b/hammond-downloader/src/downloader.rs index ef3ad0a..95b1395 100644 --- a/hammond-downloader/src/downloader.rs +++ b/hammond-downloader/src/downloader.rs @@ -129,11 +129,10 @@ pub fn get_episode( // Construct the download path. // TODO: Check if its a valid path let dlpath = format!("{}/{}.{}", dl_folder, ep.title().unwrap().to_owned(), ext); - let dlpath1 = dlpath.clone(); // info!("Downloading {:?} into: {}", y.title(), dlpath); let uri = ep.uri().to_owned(); - let res = download_to(&dlpath1, uri.as_str()); + let res = download_to(&dlpath, uri.as_str()); if let Err(err) = res { error!("Something whent wrong while downloading."); diff --git a/hammond-gtk/src/utils.rs b/hammond-gtk/src/utils.rs index 5fbb6e8..6e96e20 100644 --- a/hammond-gtk/src/utils.rs +++ b/hammond-gtk/src/utils.rs @@ -27,10 +27,9 @@ pub fn refresh_db(db: &Arc>, stack: >k::Stack) { // Create a async channel. let (sender, receiver) = channel(); - let db_clone = db.clone(); // Pass the desired arguments into the Local Thread Storage. GLOBAL.with(move |global| { - *global.borrow_mut() = Some((db_clone, stack.clone(), receiver)); + *global.borrow_mut() = Some((db.clone(), stack.clone(), receiver)); }); // The implementation of how this is done is probably terrible but it works!. @@ -52,23 +51,21 @@ pub fn refresh_db(db: &Arc>, stack: >k::Stack) { pub fn refresh_feed(db: &Arc>, stack: >k::Stack, source: &mut Source) { let (sender, receiver) = channel(); - let db_clone = db.clone(); GLOBAL.with(move |global| { - *global.borrow_mut() = Some((db_clone, stack.clone(), receiver)); + *global.borrow_mut() = Some((db.clone(), stack.clone(), receiver)); }); - let db_clone = db.clone(); - let mut source_ = source.clone(); + let db = db.clone(); + let mut source = source.clone(); // TODO: add timeout option and error reporting. thread::spawn(move || { - let db_ = db_clone.clone(); - let db_ = db_.lock().unwrap(); - let foo_ = hammond_data::index_feed::refresh_source(&db_, &mut source_, false); + let db_ = db.lock().unwrap(); + let foo_ = hammond_data::index_feed::refresh_source(&db_, &mut source, false); drop(db_); if let Ok(x) = foo_ { let Feed(mut req, s) = x; - let s = hammond_data::index_feed::complete_index_from_source(&mut req, &s, &db_clone); + let s = hammond_data::index_feed::complete_index_from_source(&mut req, &s, &db); if s.is_err() { error!("Error While trying to update the database."); error!("Error msg: {}", s.unwrap_err()); diff --git a/hammond-gtk/src/widgets/episode.rs b/hammond-gtk/src/widgets/episode.rs index 5a57022..d852363 100644 --- a/hammond-gtk/src/widgets/episode.rs +++ b/hammond-gtk/src/widgets/episode.rs @@ -85,8 +85,8 @@ fn epidose_widget( &db, &pd_title_clone, &mut ep_clone.clone(), - dl_button_clone.clone(), - play_button_clone.clone(), + &dl_button_clone, + &play_button_clone, ); }); @@ -98,15 +98,15 @@ fn on_dl_clicked( db: &Arc>, pd_title: &str, ep: &mut Episode, - dl_bttn: gtk::Button, - play_bttn: gtk::Button, + dl_bttn: >k::Button, + play_bttn: >k::Button, ) { // Create a async channel. let (sender, receiver) = channel(); // Pass the desired arguments into the Local Thread Storage. GLOBAL.with(move |global| { - *global.borrow_mut() = Some((dl_bttn, play_bttn, receiver)); + *global.borrow_mut() = Some((dl_bttn.clone(), play_bttn.clone(), receiver)); }); let pd_title = pd_title.to_owned();