Applied clippy suggestions.
This commit is contained in:
parent
ac80ab04d4
commit
25344aa613
@ -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);
|
||||
|
||||
@ -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());
|
||||
|
||||
@ -61,7 +61,7 @@ fn build_ui(app: >k::Application) {
|
||||
});
|
||||
app.add_action(&quit);
|
||||
|
||||
let db2 = db.clone();
|
||||
let db2 = Arc::clone(&db);
|
||||
let check = gio::SimpleAction::new("check", None);
|
||||
check.connect_activate(move |_, _| {
|
||||
let _ = dbcheckup::run(&db2);
|
||||
|
||||
@ -111,10 +111,10 @@ pub fn podcast_widget(
|
||||
|
||||
if let Some(t) = title {
|
||||
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);
|
||||
if let Ok(l) = f {
|
||||
if l.len() > 0 {
|
||||
if !l.is_empty() {
|
||||
played_button.show()
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user