Applied clippy suggestions.

This commit is contained in:
Jordan Petridis
2017-10-30 13:15:44 +02:00
parent ac80ab04d4
commit 25344aa613
4 changed files with 9 additions and 8 deletions
+4 -3
View File
@@ -8,6 +8,7 @@ use chrono::prelude::*;
use std::path::Path;
use std::fs;
use std::sync::Arc;
// TODO: Write unit test.
fn download_checker(db: &Database) -> Result<()> {
@@ -19,7 +20,7 @@ fn download_checker(db: &Database) -> Result<()> {
episodes.par_iter_mut().for_each(|ep| {
if !Path::new(ep.local_uri().unwrap()).exists() {
ep.set_local_uri(None);
let res = ep.save(&db.clone());
let res = ep.save(&Arc::clone(db));
if let Err(err) = res {
error!("Error while trying to update episode: {:#?}", ep);
error!("Error: {}", err);
@@ -40,11 +41,11 @@ fn watched_cleaner(db: &Database) -> Result<()> {
let now_utc = Utc::now().timestamp() as i32;
episodes.par_iter_mut().for_each(|mut ep| {
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.
let limit = watched + 172_800; // add 2days in seconds
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 {
error!("Error while trying to delete file: {:?}", ep.local_uri());
error!("Error: {}", err);
+2 -2
View File
@@ -6,7 +6,7 @@ use models;
// TODO: look into how bad-utf8 is handled in rss crate,
// and figure if there is a need for checking before parsing.
// 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 {
let title = chan.title().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 {
let title = item.title().map(|s| s.trim());
let description = item.description().map(|s| s.trim());