Some cleanup.

This commit is contained in:
Jordan Petridis 2017-09-26 10:44:25 +03:00
parent a0064fcb4f
commit 6c25bd7eaa
No known key found for this signature in database
GPG Key ID: CEABAD9F5683B9A6
2 changed files with 6 additions and 25 deletions

View File

@ -105,12 +105,9 @@ pub fn index_loop(db: SqliteConnection) -> Result<()> {
req.read_to_string(&mut buf)?;
let chan = rss::Channel::from_str(&buf)?;
let mut pd = Podcast::new();
{
let fakedb = bar.lock().unwrap();
pd = index_podcast(&fakedb, &chan, source)?;
}
let fakedb = bar.lock().unwrap();
let pd = index_podcast(&fakedb, &chan, source)?;
drop(fakedb);
let foo: Vec<_> = chan.items()
.par_iter()
@ -121,8 +118,9 @@ pub fn index_loop(db: SqliteConnection) -> Result<()> {
info!("{:#?}", foo);
let _: Vec<_> = foo.par_iter()
.map(|x| {
let z = bar.clone();
baz(z, x)
let dbmutex = bar.clone();
let db = dbmutex.lock().unwrap();
index_episode(&db, &x).unwrap();
})
.collect();
@ -132,12 +130,6 @@ pub fn index_loop(db: SqliteConnection) -> Result<()> {
Ok(())
}
fn baz(arc: Arc<Mutex<SqliteConnection>>, ep: &NewEpisode) -> Result<()> {
let db = arc.lock().unwrap();
index_episode(&db, ep)?;
Ok(())
}
// TODO: refactor into an Iterator
// TODO: After fixing etag/lmod, add sent_etag:bool arg and logic to bypass it.
pub fn fetch_feeds(connection: &SqliteConnection) -> Result<Vec<(reqwest::Response, Source)>> {

View File

@ -108,17 +108,6 @@ pub struct Podcast {
}
impl Podcast {
pub fn new() -> Podcast {
Podcast {
id: 0,
title: String::new(),
link: String::new(),
description: String::new(),
image_uri: None,
source_id: 0,
}
}
pub fn id(&self) -> i32 {
self.id
}