From 13ba2762add0ecfdb036baa47acb10f4f5c101e1 Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Fri, 5 Jan 2018 22:02:06 +0200 Subject: [PATCH] Move the download manager to the gtk crate. --- Cargo.lock | 1 - hammond-downloader/Cargo.toml | 1 - hammond-downloader/src/lib.rs | 3 -- hammond-gtk/src/app.rs | 2 +- hammond-gtk/src/main.rs | 1 + .../src/manager.rs | 43 +++++++++---------- hammond-gtk/src/widgets/episode.rs | 2 - 7 files changed, 23 insertions(+), 30 deletions(-) rename {hammond-downloader => hammond-gtk}/src/manager.rs (82%) diff --git a/Cargo.lock b/Cargo.lock index 77c05f2..ba57fd0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -599,7 +599,6 @@ dependencies = [ "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "hammond-data 0.1.0", "hyper 0.11.10 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "mime_guess 1.8.3 (registry+https://github.com/rust-lang/crates.io-index)", "reqwest 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/hammond-downloader/Cargo.toml b/hammond-downloader/Cargo.toml index 9646d26..f541ba8 100644 --- a/hammond-downloader/Cargo.toml +++ b/hammond-downloader/Cargo.toml @@ -12,7 +12,6 @@ mime_guess = "1.8.3" reqwest = "0.8.2" tempdir = "0.3.5" glob = "0.2.11" -lazy_static = "1.0.0" [dependencies.diesel] features = ["sqlite"] diff --git a/hammond-downloader/src/lib.rs b/hammond-downloader/src/lib.rs index 31cc0b2..9e57db8 100644 --- a/hammond-downloader/src/lib.rs +++ b/hammond-downloader/src/lib.rs @@ -7,8 +7,6 @@ extern crate glob; extern crate hammond_data; extern crate hyper; #[macro_use] -extern crate lazy_static; -#[macro_use] extern crate log; extern crate mime_guess; extern crate reqwest; @@ -16,4 +14,3 @@ extern crate tempdir; pub mod downloader; pub mod errors; -pub mod manager; diff --git a/hammond-gtk/src/app.rs b/hammond-gtk/src/app.rs index ada0284..d08df19 100644 --- a/hammond-gtk/src/app.rs +++ b/hammond-gtk/src/app.rs @@ -5,9 +5,9 @@ use gtk::prelude::*; use gio::{ActionMapExt, ApplicationExt, ApplicationExtManual, SimpleActionExt}; use hammond_data::utils::checkup; -use hammond_downloader::manager::Manager; use hammond_data::Source; +use manager::Manager; use headerbar::Header; use content::Content; use utils; diff --git a/hammond-gtk/src/main.rs b/hammond-gtk/src/main.rs index 622cd10..9dead41 100644 --- a/hammond-gtk/src/main.rs +++ b/hammond-gtk/src/main.rs @@ -53,6 +53,7 @@ mod content; mod app; mod utils; +mod manager; mod static_resource; use app::App; diff --git a/hammond-downloader/src/manager.rs b/hammond-gtk/src/manager.rs similarity index 82% rename from hammond-downloader/src/manager.rs rename to hammond-gtk/src/manager.rs index 53a914a..ba26036 100644 --- a/hammond-downloader/src/manager.rs +++ b/hammond-gtk/src/manager.rs @@ -1,31 +1,30 @@ -use hammond_data::Episode; +// use hammond_data::Episode; use hammond_data::dbqueries; - -use downloader::get_episode; +use hammond_downloader::downloader::get_episode; use std::collections::HashSet; use std::sync::{Arc, Mutex}; -use std::path::PathBuf; +// use std::path::PathBuf; use std::thread; -struct DonwloadInstance { - uri: String, - // FIXME: MAKE ME A PATHBUF - local_uri: Option, - downloaded_bytes: u64, - total_bytes: u64, -} +// struct DonwloadInstance { +// uri: String, +// // FIXME: MAKE ME A PATHBUF +// local_uri: Option, +// downloaded_bytes: u64, +// total_bytes: u64, +// } -impl DonwloadInstance { - fn new(url: &str, total_bytes: u64) -> Self { - DonwloadInstance { - uri: url.into(), - local_uri: None, - downloaded_bytes: 0, - total_bytes, - } - } -} +// impl DonwloadInstance { +// fn new(url: &str, total_bytes: u64) -> Self { +// DonwloadInstance { +// uri: url.into(), +// local_uri: None, +// downloaded_bytes: 0, +// total_bytes, +// } +// } +// } #[derive(Debug, Clone)] // FIXME: privacy stuff @@ -70,7 +69,7 @@ impl Manager { #[cfg(test)] mod tests { use super::*; - use downloader; + use hammond_downloader::downloader; use diesel::Identifiable; diff --git a/hammond-gtk/src/widgets/episode.rs b/hammond-gtk/src/widgets/episode.rs index c9245e8..8595883 100644 --- a/hammond-gtk/src/widgets/episode.rs +++ b/hammond-gtk/src/widgets/episode.rs @@ -14,10 +14,8 @@ use hammond_data::errors::*; use hammond_downloader::downloader; use app::DOWNLOADS_MANAGER; - use app::Action; -use std::thread; use std::sync::mpsc::Sender; use std::path::Path;