Remove dead code.

This commit is contained in:
Jordan Petridis 2018-04-14 07:52:55 +03:00
parent 1036176e51
commit f5f0a5b873
No known key found for this signature in database
GPG Key ID: CEABAD9F5683B9A6
3 changed files with 13 additions and 47 deletions

View File

@ -381,15 +381,27 @@ mod tests {
use database::*; use database::*;
use pipeline::*; use pipeline::*;
use hyper::Client;
use hyper_tls::HttpsConnector;
use tokio_core::reactor::Core;
use num_cpus;
#[test] #[test]
fn test_update_none_to_played_now() { fn test_update_none_to_played_now() {
truncate_db().unwrap(); truncate_db().unwrap();
let mut core = Core::new().unwrap();
let handle = core.handle();
let client = Client::configure()
.connector(HttpsConnector::new(num_cpus::get(), &handle).unwrap())
.build(&handle);
let url = "https://web.archive.org/web/20180120083840if_/https://feeds.feedburner.\ let url = "https://web.archive.org/web/20180120083840if_/https://feeds.feedburner.\
com/InterceptedWithJeremyScahill"; com/InterceptedWithJeremyScahill";
let source = Source::from_url(url).unwrap(); let source = Source::from_url(url).unwrap();
let id = source.id(); let id = source.id();
index_single_source(source, true).unwrap(); pipeline(vec![source], true, &mut core, client).unwrap();
let pd = get_podcast_from_source_id(id).unwrap(); let pd = get_podcast_from_source_id(id).unwrap();
let eps_num = get_pd_unplayed_episodes(&pd).unwrap().len(); let eps_num = get_pd_unplayed_episodes(&pd).unwrap().len();

View File

@ -57,8 +57,6 @@ pub enum DataError {
F301(Source), F301(Source),
#[fail(display = "Error occured while Parsing an Episode. Reason: {}", reason)] #[fail(display = "Error occured while Parsing an Episode. Reason: {}", reason)]
ParseEpisodeError { reason: String, parent_id: i32 }, ParseEpisodeError { reason: String, parent_id: i32 },
#[fail(display = "No Futures where produced to be run.")]
EmptyFuturesList,
#[fail(display = "Episode was not changed and thus skipped.")] #[fail(display = "Episode was not changed and thus skipped.")]
EpisodeNotChanged, EpisodeNotChanged,
} }

View File

@ -81,22 +81,6 @@ pub fn run(sources: Vec<Source>, ignore_etags: bool) -> Result<(), DataError> {
pipeline(sources, ignore_etags, &mut core, client) pipeline(sources, ignore_etags, &mut core, client)
} }
/// Docs
pub fn index_single_source(s: Source, ignore_etags: bool) -> Result<(), DataError> {
let mut core = Core::new()?;
let handle = core.handle();
let client = Client::configure()
.connector(HttpsConnector::new(num_cpus::get(), &handle)?)
.build(&handle);
let work = s.into_feed(client, ignore_etags)
.and_then(move |feed| feed.index())
.map(|_| ());
core.run(work)
}
fn determine_ep_state( fn determine_ep_state(
ep: NewEpisodeMinimal, ep: NewEpisodeMinimal,
item: &rss::Item, item: &rss::Item,
@ -127,34 +111,6 @@ pub(crate) fn glue_async<'a>(
) )
} }
// Weird magic from #rust irc channel
// kudos to remexre
/// FIXME: Docs
#[cfg_attr(feature = "cargo-clippy", allow(type_complexity))]
pub fn collect_futures<F>(
futures: Vec<F>,
) -> Box<Future<Item = Vec<Result<F::Item, F::Error>>, Error = DataError>>
where
F: 'static + Future,
<F as Future>::Item: 'static,
<F as Future>::Error: 'static,
{
Box::new(loop_fn((futures, vec![]), |(futures, mut done)| {
select_all(futures).then(|r| {
let (r, rest) = match r {
Ok((r, _, rest)) => (Ok(r), rest),
Err((r, _, rest)) => (Err(r), rest),
};
done.push(r);
if rest.is_empty() {
Ok(Loop::Break(done))
} else {
Ok(Loop::Continue((rest, done)))
}
})
}))
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;