Feed: Removee unimplemented! hack to guard against my future stupidity.

This commit is contained in:
Jordan Petridis 2018-01-19 19:20:21 +02:00
parent 1606ceaadb
commit 855b1517a7
No known key found for this signature in database
GPG Key ID: CEABAD9F5683B9A6
2 changed files with 19 additions and 12 deletions

2
.gitignore vendored
View File

@ -8,6 +8,6 @@ _build
vendor/ vendor/
.flatpak-builder/ .flatpak-builder/
flatpak-build/ flatpak-build/
flatpak-repo/
repo/ repo/
Makefile Makefile
.criterion

View File

@ -10,7 +10,7 @@ use models::{IndexState, Update};
use models::{NewEpisode, NewPodcast, Podcast}; use models::{NewEpisode, NewPodcast, Podcast};
use pipeline::*; use pipeline::*;
type InsertUpdate = (Vec<NewEpisode>, Vec<(NewEpisode, i32)>); type InsertUpdate = (Vec<NewEpisode>, Vec<Option<(NewEpisode, i32)>>);
#[derive(Debug)] #[derive(Debug)]
/// Wrapper struct that hold a `Source` id and the `rss::Channel` /// Wrapper struct that hold a `Source` id and the `rss::Channel`
@ -54,13 +54,16 @@ impl Feed {
}) })
.map(|(_, update)| { .map(|(_, update)| {
if !update.is_empty() { if !update.is_empty() {
info!("Updating {} episodes.", update.len()); // see get_stuff for more
update.iter().for_each(|&(ref ep, rowid)| { update
if let Err(err) = ep.update(rowid) { .into_iter()
error!("Failed to index episode: {:?}.", ep.title()); .filter_map(|x| x)
error!("Error msg: {}", err); .for_each(|(ref ep, rowid)| {
}; if let Err(err) = ep.update(rowid) {
}) error!("Failed to index episode: {:?}.", ep.title());
error!("Error msg: {}", err);
};
})
} }
}); });
@ -72,6 +75,10 @@ impl Feed {
.items() .items()
.into_iter() .into_iter()
.map(|item| glue_async(item, pd.id())) .map(|item| glue_async(item, pd.id()))
// This is sort of ugly but I think it's cheaper than pushing None
// to updated and filtering it out later.
// Even though we already map_filter in index_channel_items.
// I am not sure what the optimizations are on match vs allocating None.
.map(|fut| { .map(|fut| {
fut.and_then(|x| match x { fut.and_then(|x| match x {
IndexState::NotChanged => bail!("Nothing to do here."), IndexState::NotChanged => bail!("Nothing to do here."),
@ -81,9 +88,9 @@ impl Feed {
.flat_map(|fut| fut.wait()) .flat_map(|fut| fut.wait())
.partition_map(|state| match state { .partition_map(|state| match state {
IndexState::Index(e) => Either::Left(e), IndexState::Index(e) => Either::Left(e),
IndexState::Update(e) => Either::Right(e), IndexState::Update(e) => Either::Right(Some(e)),
// How not to use the unimplemented macro... // This should never occur
IndexState::NotChanged => unimplemented!(), IndexState::NotChanged => Either::Right(None),
}); });
Box::new(ok((insert, update))) Box::new(ok((insert, update)))