diff --git a/hammond-data/benches/bench.rs b/hammond-data/benches/bench.rs index b7f9f76..ffbaed2 100644 --- a/hammond-data/benches/bench.rs +++ b/hammond-data/benches/bench.rs @@ -108,7 +108,6 @@ fn bench_get_future_feeds(b: &mut Bencher) { b.iter(|| { let sources = hammond_data::dbqueries::get_sources().unwrap(); - hammond_data::pipeline::pipeline(sources).unwrap(); - println!("I RUN"); + hammond_data::pipeline::pipeline(sources, false).unwrap(); }) } diff --git a/hammond-data/src/models/queryables.rs b/hammond-data/src/models/queryables.rs index b8eef3c..52d53fd 100644 --- a/hammond-data/src/models/queryables.rs +++ b/hammond-data/src/models/queryables.rs @@ -6,6 +6,7 @@ use reqwest; use diesel::SaveChangesDsl; use rss::Channel; +use hyper; use hyper::client::HttpConnector; use hyper::{Client, Method, Request, Response, StatusCode, Uri}; use hyper::header::{ETag, EntityTag, HttpDate, IfModifiedSince, IfNoneMatch, LastModified}; @@ -723,16 +724,16 @@ impl Source { ) -> Box> { let id = self.id(); // TODO: make URI future - // TODO: make a status match future let feed = request_constructor(&self, client, ignore_etags) - .map(move |res| { - if let Err(err) = self.update_etag2(&res) { - error!("Failed to update Source struct with new etag values"); - error!("Error: {}", err); - }; - res - }) .map_err(From::from) + .and_then(move |res| { + self.update_etag2(&res)?; + Ok(res) + }) + .and_then(|res| -> Result { + match_status(res.status())?; + Ok(res) + }) .and_then(|res| response_to_channel(res)) .map(move |chan| Feed::from_channel_source(chan, id)); @@ -753,7 +754,7 @@ fn request_constructor( s: &Source, client: &Client>, ignore_etags: bool, -) -> Box> { +) -> Box> { // FIXME: remove unwrap let uri = Uri::from_str(&s.uri()).unwrap(); let mut req = Request::new(Method::Get, uri);