I hate Arcs and Rcs.
This commit is contained in:
parent
6ffacaa6d8
commit
02cce8b915
@ -119,8 +119,7 @@ fn complete_index(
|
|||||||
parent: &Source,
|
parent: &Source,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let pd = {
|
let pd = {
|
||||||
let db = connection.clone();
|
let db = connection.lock().unwrap();
|
||||||
let db = db.lock().unwrap();
|
|
||||||
index_channel(&db, chan, parent)?
|
index_channel(&db, chan, parent)?
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -140,8 +139,7 @@ fn index_channel_items(connection: &Arc<Mutex<SqliteConnection>>, it: &[rss::Ite
|
|||||||
it.par_iter()
|
it.par_iter()
|
||||||
.map(|x| feedparser::parse_episode(x, pd.id()))
|
.map(|x| feedparser::parse_episode(x, pd.id()))
|
||||||
.for_each(|x| {
|
.for_each(|x| {
|
||||||
let db = connection.clone();
|
let db = connection.lock().unwrap();
|
||||||
let db = db.lock().unwrap();
|
|
||||||
let e = index_episode(&db, &x);
|
let e = index_episode(&db, &x);
|
||||||
if let Err(err) = e {
|
if let Err(err) = e {
|
||||||
error!("Failed to index episode: {:?}.", x);
|
error!("Failed to index episode: {:?}.", x);
|
||||||
|
|||||||
@ -129,11 +129,10 @@ pub fn get_episode(
|
|||||||
// Construct the download path.
|
// Construct the download path.
|
||||||
// TODO: Check if its a valid path
|
// TODO: Check if its a valid path
|
||||||
let dlpath = format!("{}/{}.{}", dl_folder, ep.title().unwrap().to_owned(), ext);
|
let dlpath = format!("{}/{}.{}", dl_folder, ep.title().unwrap().to_owned(), ext);
|
||||||
let dlpath1 = dlpath.clone();
|
|
||||||
// info!("Downloading {:?} into: {}", y.title(), dlpath);
|
// info!("Downloading {:?} into: {}", y.title(), dlpath);
|
||||||
|
|
||||||
let uri = ep.uri().to_owned();
|
let uri = ep.uri().to_owned();
|
||||||
let res = download_to(&dlpath1, uri.as_str());
|
let res = download_to(&dlpath, uri.as_str());
|
||||||
|
|
||||||
if let Err(err) = res {
|
if let Err(err) = res {
|
||||||
error!("Something whent wrong while downloading.");
|
error!("Something whent wrong while downloading.");
|
||||||
|
|||||||
@ -27,10 +27,9 @@ pub fn refresh_db(db: &Arc<Mutex<SqliteConnection>>, stack: >k::Stack) {
|
|||||||
// Create a async channel.
|
// Create a async channel.
|
||||||
let (sender, receiver) = channel();
|
let (sender, receiver) = channel();
|
||||||
|
|
||||||
let db_clone = db.clone();
|
|
||||||
// Pass the desired arguments into the Local Thread Storage.
|
// Pass the desired arguments into the Local Thread Storage.
|
||||||
GLOBAL.with(move |global| {
|
GLOBAL.with(move |global| {
|
||||||
*global.borrow_mut() = Some((db_clone, stack.clone(), receiver));
|
*global.borrow_mut() = Some((db.clone(), stack.clone(), receiver));
|
||||||
});
|
});
|
||||||
|
|
||||||
// The implementation of how this is done is probably terrible but it works!.
|
// The implementation of how this is done is probably terrible but it works!.
|
||||||
@ -52,23 +51,21 @@ pub fn refresh_db(db: &Arc<Mutex<SqliteConnection>>, stack: >k::Stack) {
|
|||||||
pub fn refresh_feed(db: &Arc<Mutex<SqliteConnection>>, stack: >k::Stack, source: &mut Source) {
|
pub fn refresh_feed(db: &Arc<Mutex<SqliteConnection>>, stack: >k::Stack, source: &mut Source) {
|
||||||
let (sender, receiver) = channel();
|
let (sender, receiver) = channel();
|
||||||
|
|
||||||
let db_clone = db.clone();
|
|
||||||
GLOBAL.with(move |global| {
|
GLOBAL.with(move |global| {
|
||||||
*global.borrow_mut() = Some((db_clone, stack.clone(), receiver));
|
*global.borrow_mut() = Some((db.clone(), stack.clone(), receiver));
|
||||||
});
|
});
|
||||||
|
|
||||||
let db_clone = db.clone();
|
let db = db.clone();
|
||||||
let mut source_ = source.clone();
|
let mut source = source.clone();
|
||||||
// TODO: add timeout option and error reporting.
|
// TODO: add timeout option and error reporting.
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
let db_ = db_clone.clone();
|
let db_ = db.lock().unwrap();
|
||||||
let db_ = db_.lock().unwrap();
|
let foo_ = hammond_data::index_feed::refresh_source(&db_, &mut source, false);
|
||||||
let foo_ = hammond_data::index_feed::refresh_source(&db_, &mut source_, false);
|
|
||||||
drop(db_);
|
drop(db_);
|
||||||
|
|
||||||
if let Ok(x) = foo_ {
|
if let Ok(x) = foo_ {
|
||||||
let Feed(mut req, s) = x;
|
let Feed(mut req, s) = x;
|
||||||
let s = hammond_data::index_feed::complete_index_from_source(&mut req, &s, &db_clone);
|
let s = hammond_data::index_feed::complete_index_from_source(&mut req, &s, &db);
|
||||||
if s.is_err() {
|
if s.is_err() {
|
||||||
error!("Error While trying to update the database.");
|
error!("Error While trying to update the database.");
|
||||||
error!("Error msg: {}", s.unwrap_err());
|
error!("Error msg: {}", s.unwrap_err());
|
||||||
|
|||||||
@ -85,8 +85,8 @@ fn epidose_widget(
|
|||||||
&db,
|
&db,
|
||||||
&pd_title_clone,
|
&pd_title_clone,
|
||||||
&mut ep_clone.clone(),
|
&mut ep_clone.clone(),
|
||||||
dl_button_clone.clone(),
|
&dl_button_clone,
|
||||||
play_button_clone.clone(),
|
&play_button_clone,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -98,15 +98,15 @@ fn on_dl_clicked(
|
|||||||
db: &Arc<Mutex<SqliteConnection>>,
|
db: &Arc<Mutex<SqliteConnection>>,
|
||||||
pd_title: &str,
|
pd_title: &str,
|
||||||
ep: &mut Episode,
|
ep: &mut Episode,
|
||||||
dl_bttn: gtk::Button,
|
dl_bttn: >k::Button,
|
||||||
play_bttn: gtk::Button,
|
play_bttn: >k::Button,
|
||||||
) {
|
) {
|
||||||
// Create a async channel.
|
// Create a async channel.
|
||||||
let (sender, receiver) = channel();
|
let (sender, receiver) = channel();
|
||||||
|
|
||||||
// Pass the desired arguments into the Local Thread Storage.
|
// Pass the desired arguments into the Local Thread Storage.
|
||||||
GLOBAL.with(move |global| {
|
GLOBAL.with(move |global| {
|
||||||
*global.borrow_mut() = Some((dl_bttn, play_bttn, receiver));
|
*global.borrow_mut() = Some((dl_bttn.clone(), play_bttn.clone(), receiver));
|
||||||
});
|
});
|
||||||
|
|
||||||
let pd_title = pd_title.to_owned();
|
let pd_title = pd_title.to_owned();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user