Applied clippy suggestions.

This commit is contained in:
Jordan Petridis 2017-10-30 13:15:44 +02:00
parent ac80ab04d4
commit 25344aa613
No known key found for this signature in database
GPG Key ID: CEABAD9F5683B9A6
4 changed files with 9 additions and 8 deletions

View File

@ -8,6 +8,7 @@ use chrono::prelude::*;
use std::path::Path; use std::path::Path;
use std::fs; use std::fs;
use std::sync::Arc;
// TODO: Write unit test. // TODO: Write unit test.
fn download_checker(db: &Database) -> Result<()> { fn download_checker(db: &Database) -> Result<()> {
@ -19,7 +20,7 @@ fn download_checker(db: &Database) -> Result<()> {
episodes.par_iter_mut().for_each(|ep| { episodes.par_iter_mut().for_each(|ep| {
if !Path::new(ep.local_uri().unwrap()).exists() { if !Path::new(ep.local_uri().unwrap()).exists() {
ep.set_local_uri(None); ep.set_local_uri(None);
let res = ep.save(&db.clone()); let res = ep.save(&Arc::clone(db));
if let Err(err) = res { if let Err(err) = res {
error!("Error while trying to update episode: {:#?}", ep); error!("Error while trying to update episode: {:#?}", ep);
error!("Error: {}", err); error!("Error: {}", err);
@ -40,11 +41,11 @@ fn watched_cleaner(db: &Database) -> Result<()> {
let now_utc = Utc::now().timestamp() as i32; let now_utc = Utc::now().timestamp() as i32;
episodes.par_iter_mut().for_each(|mut ep| { episodes.par_iter_mut().for_each(|mut ep| {
if ep.local_uri().is_some() && ep.watched().is_some() { if ep.local_uri().is_some() && ep.watched().is_some() {
let watched = ep.watched().unwrap().clone(); let watched = ep.watched().unwrap();
// TODO: expose a config and a user set option. // TODO: expose a config and a user set option.
let limit = watched + 172_800; // add 2days in seconds let limit = watched + 172_800; // add 2days in seconds
if now_utc > limit { if now_utc > limit {
let e = delete_local_content(&db.clone(), &mut ep); let e = delete_local_content(&Arc::clone(db), &mut ep);
if let Err(err) = e { if let Err(err) = e {
error!("Error while trying to delete file: {:?}", ep.local_uri()); error!("Error while trying to delete file: {:?}", ep.local_uri());
error!("Error: {}", err); error!("Error: {}", err);

View File

@ -6,7 +6,7 @@ use models;
// TODO: look into how bad-utf8 is handled in rss crate, // TODO: look into how bad-utf8 is handled in rss crate,
// and figure if there is a need for checking before parsing. // and figure if there is a need for checking before parsing.
// TODO: Extend the support for parsing itunes extensions // TODO: Extend the support for parsing itunes extensions
/// Parses a rss::Channel into a NewPodcast Struct. /// Parses a `rss::Channel` into a `NewPodcast` Struct.
pub fn parse_podcast(chan: &Channel, source_id: i32) -> models::NewPodcast { pub fn parse_podcast(chan: &Channel, source_id: i32) -> models::NewPodcast {
let title = chan.title().trim().to_owned(); let title = chan.title().trim().to_owned();
let link = chan.link().trim().to_owned(); let link = chan.link().trim().to_owned();
@ -30,7 +30,7 @@ pub fn parse_podcast(chan: &Channel, source_id: i32) -> models::NewPodcast {
} }
} }
/// Parses a rss::Item into a NewEpisode Struct. /// Parses an `rss::Item` into a `NewEpisode` Struct.
pub fn parse_episode(item: &Item, parent_id: i32) -> models::NewEpisode { pub fn parse_episode(item: &Item, parent_id: i32) -> models::NewEpisode {
let title = item.title().map(|s| s.trim()); let title = item.title().map(|s| s.trim());
let description = item.description().map(|s| s.trim()); let description = item.description().map(|s| s.trim());

View File

@ -61,7 +61,7 @@ fn build_ui(app: &gtk::Application) {
}); });
app.add_action(&quit); app.add_action(&quit);
let db2 = db.clone(); let db2 = Arc::clone(&db);
let check = gio::SimpleAction::new("check", None); let check = gio::SimpleAction::new("check", None);
check.connect_activate(move |_, _| { check.connect_activate(move |_, _| {
let _ = dbcheckup::run(&db2); let _ = dbcheckup::run(&db2);

View File

@ -111,10 +111,10 @@ pub fn podcast_widget(
if let Some(t) = title { if let Some(t) = title {
let tempdb = db.lock().unwrap(); let tempdb = db.lock().unwrap();
let parent = dbqueries::load_podcast_from_title(&tempdb, &t).unwrap(); let parent = dbqueries::load_podcast_from_title(&tempdb, t).unwrap();
let f = dbqueries::get_pd_unplayed_episodes(&tempdb, &parent); let f = dbqueries::get_pd_unplayed_episodes(&tempdb, &parent);
if let Ok(l) = f { if let Ok(l) = f {
if l.len() > 0 { if !l.is_empty() {
played_button.show() played_button.show()
} }
} }