diff --git a/src/index_feed.rs b/src/index_feed.rs index 19ecf15..605f283 100644 --- a/src/index_feed.rs +++ b/src/index_feed.rs @@ -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>, 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> { diff --git a/src/models.rs b/src/models.rs index 3f594bd..ccb8564 100644 --- a/src/models.rs +++ b/src/models.rs @@ -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 }