Cargo clippy and fmt.
This commit is contained in:
@@ -96,7 +96,7 @@ impl Feed {
|
||||
// I am not sure what the optimizations are on match vs allocating None.
|
||||
.map(|fut| {
|
||||
fut.and_then(|x| match x {
|
||||
IndexState::NotChanged => return Err(DataError::EpisodeNotChanged),
|
||||
IndexState::NotChanged => Err(DataError::EpisodeNotChanged),
|
||||
_ => Ok(x),
|
||||
})
|
||||
})
|
||||
|
||||
@@ -32,7 +32,8 @@ pub struct Episode {
|
||||
}
|
||||
|
||||
impl Save<Episode, DataError> for Episode {
|
||||
/// Helper method to easily save/"sync" current state of self to the Database.
|
||||
/// Helper method to easily save/"sync" current state of self to the
|
||||
/// Database.
|
||||
fn save(&self) -> Result<Episode, DataError> {
|
||||
let db = connection();
|
||||
let tempdb = db.get()?;
|
||||
@@ -224,7 +225,8 @@ impl From<Episode> for EpisodeWidgetQuery {
|
||||
}
|
||||
|
||||
impl Save<usize, DataError> for EpisodeWidgetQuery {
|
||||
/// Helper method to easily save/"sync" current state of self to the Database.
|
||||
/// Helper method to easily save/"sync" current state of self to the
|
||||
/// Database.
|
||||
fn save(&self) -> Result<usize, DataError> {
|
||||
use schema::episode::dsl::*;
|
||||
|
||||
@@ -362,7 +364,8 @@ pub struct EpisodeCleanerQuery {
|
||||
}
|
||||
|
||||
impl Save<usize, DataError> for EpisodeCleanerQuery {
|
||||
/// Helper method to easily save/"sync" current state of self to the Database.
|
||||
/// Helper method to easily save/"sync" current state of self to the
|
||||
/// Database.
|
||||
fn save(&self) -> Result<usize, DataError> {
|
||||
use schema::episode::dsl::*;
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ pub trait Index<T, E>: Insert<T, E> + Update<T, E> {
|
||||
|
||||
/// FIXME: DOCS
|
||||
pub trait Save<T, E> {
|
||||
/// Helper method to easily save/"sync" current state of a diesel model to the Database.
|
||||
/// Helper method to easily save/"sync" current state of a diesel model to
|
||||
/// the Database.
|
||||
fn save(&self) -> Result<T, E>;
|
||||
}
|
||||
|
||||
@@ -74,7 +74,8 @@ impl Update<(), DataError> for NewEpisode {
|
||||
}
|
||||
|
||||
impl Index<(), DataError> for NewEpisode {
|
||||
// Does not update the episode description if it's the only thing that has changed.
|
||||
// Does not update the episode description if it's the only thing that has
|
||||
// changed.
|
||||
fn index(&self) -> Result<(), DataError> {
|
||||
let exists = dbqueries::episode_exists(self.title(), self.podcast_id())?;
|
||||
|
||||
@@ -185,7 +186,7 @@ impl NewEpisodeMinimal {
|
||||
pub(crate) fn new(item: &rss::Item, parent_id: i32) -> Result<Self, DataError> {
|
||||
if item.title().is_none() {
|
||||
let err = DataError::ParseEpisodeError {
|
||||
reason: format!("No title specified for this Episode."),
|
||||
reason: "No title specified for this Episode.".into(),
|
||||
parent_id,
|
||||
};
|
||||
|
||||
@@ -201,7 +202,7 @@ impl NewEpisodeMinimal {
|
||||
item.link().map(|s| url_cleaner(s))
|
||||
} else {
|
||||
let err = DataError::ParseEpisodeError {
|
||||
reason: format!("No url specified for the item."),
|
||||
reason: "No url specified for the item.".into(),
|
||||
parent_id,
|
||||
};
|
||||
|
||||
|
||||
@@ -343,7 +343,8 @@ mod tests {
|
||||
#[test]
|
||||
// TODO: Add more test/checks
|
||||
// Currently there's a test that only checks new description or title.
|
||||
// If you have time and want to help, implement the test for the other fields too.
|
||||
// If you have time and want to help, implement the test for the other fields
|
||||
// too.
|
||||
fn test_new_podcast_update() {
|
||||
truncate_db().unwrap();
|
||||
let old = EXPECTED_INTERCEPTED.to_podcast().unwrap();
|
||||
|
||||
@@ -26,7 +26,8 @@ pub struct Podcast {
|
||||
}
|
||||
|
||||
impl Save<Podcast, DataError> for Podcast {
|
||||
/// Helper method to easily save/"sync" current state of self to the Database.
|
||||
/// Helper method to easily save/"sync" current state of self to the
|
||||
/// Database.
|
||||
fn save(&self) -> Result<Podcast, DataError> {
|
||||
let db = connection();
|
||||
let tempdb = db.get()?;
|
||||
|
||||
@@ -34,7 +34,8 @@ pub struct Source {
|
||||
}
|
||||
|
||||
impl Save<Source, DataError> for Source {
|
||||
/// Helper method to easily save/"sync" current state of self to the Database.
|
||||
/// Helper method to easily save/"sync" current state of self to the
|
||||
/// Database.
|
||||
fn save(&self) -> Result<Source, DataError> {
|
||||
let db = connection();
|
||||
let con = db.get()?;
|
||||
@@ -119,7 +120,7 @@ impl Source {
|
||||
let err = DataError::HttpStatusError {
|
||||
url: self.uri,
|
||||
status_code: code,
|
||||
context: format!("304: skipping.."),
|
||||
context: "304: skipping..".into(),
|
||||
};
|
||||
|
||||
return Err(err);
|
||||
@@ -131,7 +132,7 @@ impl Source {
|
||||
let err = DataError::HttpStatusError {
|
||||
url: self.uri,
|
||||
status_code: code,
|
||||
context: format!("301: Feed was moved permanently."),
|
||||
context: "301: Feed was moved permanently.".into(),
|
||||
};
|
||||
|
||||
return Err(err);
|
||||
@@ -142,7 +143,7 @@ impl Source {
|
||||
let err = DataError::HttpStatusError {
|
||||
url: self.uri,
|
||||
status_code: code,
|
||||
context: format!("401: Unauthorized."),
|
||||
context: "401: Unauthorized.".into(),
|
||||
};
|
||||
|
||||
return Err(err);
|
||||
@@ -151,17 +152,25 @@ impl Source {
|
||||
let err = DataError::HttpStatusError {
|
||||
url: self.uri,
|
||||
status_code: code,
|
||||
context: format!("403: Forbidden."),
|
||||
context: "403: Forbidden.".into(),
|
||||
};
|
||||
|
||||
return Err(err);
|
||||
}
|
||||
StatusCode::NotFound => {
|
||||
let err = DataError::HttpStatusError {
|
||||
url: self.uri,
|
||||
status_code: code,
|
||||
context: "404: Not found.".into(),
|
||||
};
|
||||
|
||||
return Err(err);
|
||||
}
|
||||
StatusCode::NotFound => return Err(format!("404: Not found.")).map_err(From::from),
|
||||
StatusCode::RequestTimeout => {
|
||||
let err = DataError::HttpStatusError {
|
||||
url: self.uri,
|
||||
status_code: code,
|
||||
context: format!("408: Request Timeout."),
|
||||
context: "408: Request Timeout.".into(),
|
||||
};
|
||||
|
||||
return Err(err);
|
||||
@@ -170,7 +179,7 @@ impl Source {
|
||||
let err = DataError::HttpStatusError {
|
||||
url: self.uri,
|
||||
status_code: code,
|
||||
context: format!("410: Feed was deleted.."),
|
||||
context: "410: Feed was deleted..".into(),
|
||||
};
|
||||
|
||||
return Err(err);
|
||||
@@ -267,6 +276,7 @@ impl Source {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(needless_pass_by_value)]
|
||||
fn response_to_channel(
|
||||
res: Response,
|
||||
pool: CpuPool,
|
||||
|
||||
@@ -67,7 +67,8 @@ pub fn pipeline<S: IntoIterator<Item = Source>>(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Creates a tokio `reactor::Core`, a `CpuPool`, and a `hyper::Client` and runs the pipeline.
|
||||
/// Creates a tokio `reactor::Core`, a `CpuPool`, and a `hyper::Client` and
|
||||
/// runs the pipeline.
|
||||
pub fn run(sources: Vec<Source>, ignore_etags: bool) -> Result<(), DataError> {
|
||||
if sources.is_empty() {
|
||||
return Ok(());
|
||||
|
||||
@@ -14,7 +14,8 @@ use xdg_dirs::DL_DIR;
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
|
||||
/// Scan downloaded `episode` entries that might have broken `local_uri`s and set them to `None`.
|
||||
/// Scan downloaded `episode` entries that might have broken `local_uri`s and
|
||||
/// set them to `None`.
|
||||
fn download_checker() -> Result<(), DataError> {
|
||||
let mut episodes = dbqueries::get_downloaded_episodes()?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user