diff --git a/hammond-data/Cargo.toml b/hammond-data/Cargo.toml index de53500..8d97eef 100644 --- a/hammond-data/Cargo.toml +++ b/hammond-data/Cargo.toml @@ -4,24 +4,13 @@ version = "0.1.0" authors = ["Jordan Petridis "] [dependencies] -rfc822_sanitizer = "0.3.0" rayon = "0.8.2" -regex = "0.2" error-chain = "0.11.0" -structopt = "0.1.0" -structopt-derive = "0.1.0" log = "0.3.8" loggerv = "0.3.0" reqwest = "0.7.3" -hyper = "0.11.2" diesel = { version = "0.16.0", features = ["sqlite", "deprecated-time", "chrono"] } diesel_codegen = { version = "0.16.0", features = ["sqlite"] } -time = "0.1.38" xdg = "2.1.0" lazy_static = "0.2.8" -chrono = "0.4.0" -rss = { version = "1.1.0", features = ["from_url"]} -# overide diesel's dependancy that would otherwise turn a dotenv feature of -# that rss depends upon -dotenv = "*" diff --git a/hammond-data/src/lib.rs b/hammond-data/src/lib.rs index 2fe0501..46ca47a 100644 --- a/hammond-data/src/lib.rs +++ b/hammond-data/src/lib.rs @@ -15,14 +15,8 @@ extern crate diesel; #[macro_use] extern crate diesel_codegen; -extern crate chrono; -extern crate hyper; extern crate rayon; -extern crate regex; extern crate reqwest; -extern crate rfc822_sanitizer; -extern crate rss; -extern crate time; extern crate xdg; pub mod dbqueries; @@ -31,33 +25,13 @@ pub mod schema; pub mod errors { - use reqwest; - use rss; - use chrono; - use hyper; - use time; use diesel::migrations::RunMigrationsError; use diesel::result; - use regex; - - use std::io; - // use std::option; - // use std::sync; error_chain! { foreign_links { - ReqError(reqwest::Error); - IoError(io::Error); - Log(::log::SetLoggerError); MigrationError(RunMigrationsError); - RSSError(rss::Error); DieselResultError(result::Error); - ChronoError(chrono::ParseError); - DurationError(time::OutOfRangeError); - HyperError(hyper::error::Error); - RegexError(regex::Error); - // NoneError(option::NoneError); - // MutexPoison(sync::PoisonError); } } } @@ -109,6 +83,7 @@ pub fn init() -> Result<()> { } pub fn run_migration_on(connection: &SqliteConnection) -> Result<()> { + info!("Running DB Migrations..."); embedded_migrations::run_with_output(connection, &mut std::io::stdout())?; Ok(()) } diff --git a/hammond-data/src/models.rs b/hammond-data/src/models.rs index d0fd6e9..c2b1125 100644 --- a/hammond-data/src/models.rs +++ b/hammond-data/src/models.rs @@ -1,5 +1,4 @@ use reqwest; -use rss::Channel; use diesel::SaveChangesDsl; use SqliteConnection; use reqwest::header::{ETag, LastModified}; diff --git a/other/src/downloader.rs b/other/src/downloader.rs index ba4f88c..08281a5 100644 --- a/other/src/downloader.rs +++ b/other/src/downloader.rs @@ -6,7 +6,7 @@ use std::fs::{rename, DirBuilder, File}; use std::io::{BufWriter, Read, Write}; use std::path::Path; -use hammond_data::errors::*; +use errors::*; use hammond_data::dbqueries; // Adapted from https://github.com/mattgathu/rget . diff --git a/other/src/errors.rs b/other/src/errors.rs new file mode 100644 index 0000000..5f989c5 --- /dev/null +++ b/other/src/errors.rs @@ -0,0 +1,19 @@ +use reqwest; +use rss; +use hyper; +use diesel::result; +use hammond_data; + +use std::io; + +error_chain! { + foreign_links { + ReqError(reqwest::Error); + IoError(io::Error); + Log(::log::SetLoggerError); + RSSError(rss::Error); + DieselResultError(result::Error); + HyperError(hyper::error::Error); + HamDBError(hammond_data::errors::Error); + } +} \ No newline at end of file diff --git a/other/src/feedparser.rs b/other/src/feedparser.rs index 672747a..29c7944 100644 --- a/other/src/feedparser.rs +++ b/other/src/feedparser.rs @@ -2,7 +2,7 @@ use rss::{Channel, Item}; use rfc822_sanitizer::parse_from_rfc2822_with_fallback; use hammond_data::models; -use hammond_data::errors::*; +use errors::*; pub fn parse_podcast(chan: &Channel, source_id: i32) -> Result { let title = chan.title().to_owned(); diff --git a/other/src/index_feed.rs b/other/src/index_feed.rs index e5d7c73..7beb575 100644 --- a/other/src/index_feed.rs +++ b/other/src/index_feed.rs @@ -9,8 +9,9 @@ use std::sync::{Arc, Mutex}; use hammond_data::schema; use hammond_data::dbqueries; -use hammond_data::errors::*; use hammond_data::models::*; + +use errors::*; use feedparser; fn index_source(con: &SqliteConnection, foo: &NewSource) -> Result<()> { diff --git a/other/src/lib.rs b/other/src/lib.rs index 98e2363..a329db0 100644 --- a/other/src/lib.rs +++ b/other/src/lib.rs @@ -1,4 +1,4 @@ -#![feature(use_extern_macros)] +#![recursion_limit = "1024"] extern crate diesel; extern crate hammond_data; @@ -9,7 +9,10 @@ extern crate rayon; extern crate reqwest; extern crate rfc822_sanitizer; extern crate rss; +#[macro_use] +extern crate error_chain; pub mod feedparser; pub mod downloader; pub mod index_feed; +pub mod errors; \ No newline at end of file diff --git a/other/src/main.rs b/other/src/main.rs index e44ab9f..6edf81e 100644 --- a/other/src/main.rs +++ b/other/src/main.rs @@ -12,8 +12,8 @@ extern crate hammond_data; extern crate other; use structopt::StructOpt; -use hammond_data::errors::*; use hammond_data::dbqueries; +use other::errors::*; use other::downloader; use other::index_feed;