diff --git a/src/feedparser.rs b/src/feedparser.rs index 449957c..2da8e4e 100644 --- a/src/feedparser.rs +++ b/src/feedparser.rs @@ -61,7 +61,7 @@ pub fn parse_episode<'a>(item: &'a Item, parent_id: i32) -> Result bar.timestamp() as i32, Err(baz) => { error!("Error while trying to parse \"{}\" as date.", foo); - error!("{}", baz); + error!("Error: {}", baz); debug!("Falling back to default 0"); 0 } @@ -344,7 +344,9 @@ mod tests { assert_eq!(i.length, Some(15077388)); assert_eq!( i.guid, - Some("https://request-for-explanation.github.io/podcast/ep9-a-once-in-a-lifetime-rfc/",) + Some( + "https://request-for-explanation.github.io/podcast/ep9-a-once-in-a-lifetime-rfc/", + ) ); assert_eq!(i.published_date, Some("Mon, 28 Aug 2017 15:00:00 PDT")); // Need to fix datetime parser first diff --git a/src/index_feed.rs b/src/index_feed.rs index 9b06ab1..79e07d6 100644 --- a/src/index_feed.rs +++ b/src/index_feed.rs @@ -59,13 +59,12 @@ fn index_podcast( let pd = feedparser::parse_podcast(channel, parent.id())?; match dbqueries::load_podcast(con, &pd.title) { - Ok(mut foo) => { - // TODO: Cmp first before replacing + Ok(mut foo) => if foo.link() != pd.link || foo.description() != pd.description { foo.set_link(&pd.link); foo.set_description(&pd.description); foo.set_image_uri(pd.image_uri.as_ref().map(|s| s.as_str())); foo.save_changes::(con)?; - } + }, Err(_) => { diesel::insert(&pd) .into(schema::podcast::table) @@ -80,8 +79,7 @@ fn index_episode(con: &SqliteConnection, item: &rss::Item, parent: &Podcast) -> let ep = feedparser::parse_episode(item, parent.id())?; match dbqueries::load_episode(con, &ep.uri.unwrap()) { - Ok(mut foo) => { - // TODO: Cmp first before replacing + Ok(mut foo) => if foo.title() != ep.title || foo.published_date() != ep.published_date { foo.set_title(ep.title); foo.set_description(ep.description); foo.set_published_date(ep.published_date); @@ -89,7 +87,7 @@ fn index_episode(con: &SqliteConnection, item: &rss::Item, parent: &Podcast) -> foo.set_length(ep.length); foo.set_epoch(ep.epoch); foo.save_changes::(con)?; - } + }, Err(_) => { diesel::insert(&ep) .into(schema::episode::table)