Wire up the callbacks to the client.
This commit is contained in:
parent
13ba2762ad
commit
da459707be
@ -2,8 +2,11 @@
|
|||||||
use hammond_data::dbqueries;
|
use hammond_data::dbqueries;
|
||||||
use hammond_downloader::downloader::get_episode;
|
use hammond_downloader::downloader::get_episode;
|
||||||
|
|
||||||
|
use app::Action;
|
||||||
|
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
use std::sync::mpsc::Sender;
|
||||||
// use std::path::PathBuf;
|
// use std::path::PathBuf;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
|
||||||
@ -45,7 +48,7 @@ impl Manager {
|
|||||||
Manager::default()
|
Manager::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add(&self, id: i32, directory: &str) {
|
pub fn add(&self, id: i32, directory: &str, sender: Sender<Action>) {
|
||||||
{
|
{
|
||||||
let mut m = self.active.lock().unwrap();
|
let mut m = self.active.lock().unwrap();
|
||||||
m.insert(id);
|
m.insert(id);
|
||||||
@ -60,8 +63,11 @@ impl Manager {
|
|||||||
error!("Error: {}", err);
|
error!("Error: {}", err);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
{
|
||||||
let mut m = list.lock().unwrap();
|
let mut m = list.lock().unwrap();
|
||||||
m.remove(&id);
|
m.remove(&id);
|
||||||
|
}
|
||||||
|
sender.send(Action::RefreshViews).unwrap();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -80,6 +86,7 @@ mod tests {
|
|||||||
|
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::{thread, time};
|
use std::{thread, time};
|
||||||
|
use std::sync::mpsc::channel;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
// This test inserts an rss feed to your `XDG_DATA/hammond/hammond.db` so we make it explicit
|
// This test inserts an rss feed to your `XDG_DATA/hammond/hammond.db` so we make it explicit
|
||||||
@ -108,12 +115,14 @@ mod tests {
|
|||||||
.unwrap()
|
.unwrap()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let (sender, _rx) = channel();
|
||||||
|
|
||||||
let manager = Manager::new();
|
let manager = Manager::new();
|
||||||
let download_fold = downloader::get_download_folder(&pd.title()).unwrap();
|
let download_fold = downloader::get_download_folder(&pd.title()).unwrap();
|
||||||
manager.add(episode.rowid(), download_fold.as_str());
|
manager.add(episode.rowid(), download_fold.as_str(), sender);
|
||||||
|
|
||||||
// Give it soem time to download the file
|
// Give it soem time to download the file
|
||||||
thread::sleep(time::Duration::from_secs(20));
|
thread::sleep(time::Duration::from_secs(40));
|
||||||
|
|
||||||
let final_path = format!("{}/{}.unknown", &download_fold, episode.rowid());
|
let final_path = format!("{}/{}.unknown", &download_fold, episode.rowid());
|
||||||
println!("{}", &final_path);
|
println!("{}", &final_path);
|
||||||
|
|||||||
@ -239,7 +239,7 @@ fn on_download_clicked(
|
|||||||
let download_fold = downloader::get_download_folder(&pd_title).unwrap();
|
let download_fold = downloader::get_download_folder(&pd_title).unwrap();
|
||||||
{
|
{
|
||||||
let man = DOWNLOADS_MANAGER.lock().unwrap();
|
let man = DOWNLOADS_MANAGER.lock().unwrap();
|
||||||
man.add(ep.rowid(), &download_fold);
|
man.add(ep.rowid(), &download_fold, sender.clone());
|
||||||
}
|
}
|
||||||
sender.send(Action::RefreshEpisodesViewBGR).unwrap();
|
sender.send(Action::RefreshEpisodesViewBGR).unwrap();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user