diff --git a/src/output/desktop.rs b/src/output/desktop.rs
index bcf65742..b3e7e534 100644
--- a/src/output/desktop.rs
+++ b/src/output/desktop.rs
@@ -4,10 +4,7 @@ use std::{
path::Path,
process,
process::{Command, Stdio},
- sync::{
- mpsc::channel,
- Arc, Mutex,
- },
+ sync::{mpsc::channel, Arc, Mutex},
thread::sleep,
time::Duration,
};
@@ -46,10 +43,7 @@ pub fn play(config: Config) {
debug!("Monitor folder: {}>", path);
- runtime.spawn(watch_folder(
- receiver,
- Arc::clone(&folder_source.nodes),
- ));
+ runtime.spawn(watch_folder(receiver, Arc::clone(&folder_source.nodes)));
Box::new(folder_source) as Box>
}
@@ -107,11 +101,11 @@ pub fn play(config: Config) {
for node in get_source {
let cmd = match node.cmd {
Some(cmd) => cmd,
- None => break
+ None => break,
};
if !node.process.unwrap() {
- continue
+ continue;
}
info!(
diff --git a/src/utils/json_reader.rs b/src/utils/json_reader.rs
index 60d1f08f..e5513966 100644
--- a/src/utils/json_reader.rs
+++ b/src/utils/json_reader.rs
@@ -3,7 +3,7 @@ use std::{fs::File, path::Path};
use simplelog::*;
-use crate::utils::{get_date, get_sec, modified_time, seek_and_length, time_to_sec, Config, Media};
+use crate::utils::{get_date, modified_time, seek_and_length, time_to_sec, Config, Media};
pub const DUMMY_LEN: f64 = 20.0;
@@ -51,7 +51,8 @@ pub fn read_json(config: &Config, seek: bool, next_start: f64) -> Playlist {
if !playlist_path.is_file() {
error!("Playlist {}> not exists!", current_file);
- return Playlist::new(date, get_sec());
+ // let dummy_playlist = Playlist::new(date, get_sec());
+ return Playlist::new(date, start_sec);
}
info!("Read Playlist: {}>", ¤t_file);
diff --git a/src/utils/playlist.rs b/src/utils/playlist.rs
index 8779014a..fd147f76 100644
--- a/src/utils/playlist.rs
+++ b/src/utils/playlist.rs
@@ -11,7 +11,7 @@ use crate::utils::{
pub struct CurrentProgram {
config: Config,
start_sec: f64,
- json_mod: String,
+ json_mod: Option,
json_path: Option,
nodes: Vec,
current_node: Media,
@@ -26,8 +26,8 @@ impl CurrentProgram {
Self {
config,
start_sec: json.start_sec.unwrap(),
- json_mod: json.modified.unwrap(),
- json_path: Some(json.current_file.unwrap()),
+ json_mod: json.modified,
+ json_path: json.current_file,
nodes: json.program,
current_node: Media::new(0, "".to_string()),
init: true,
@@ -41,12 +41,16 @@ impl CurrentProgram {
if Path::new(&path).is_file() {
let mod_time = modified_time(path);
- if !mod_time.unwrap().to_string().eq(&self.json_mod) {
+ if !mod_time
+ .unwrap()
+ .to_string()
+ .eq(&self.json_mod.clone().unwrap())
+ {
// when playlist has changed, reload it
let json = read_json(&self.config, false, 0.0);
- self.json_mod = json.modified.unwrap();
- self.nodes = json.program.into();
+ self.json_mod = json.modified;
+ self.nodes = json.program;
}
} else {
error!("Playlist {}> not exists!", path);
@@ -61,7 +65,6 @@ impl CurrentProgram {
self.init = true;
self.index = 0;
}
-
}
_ => (),
@@ -94,8 +97,8 @@ impl CurrentProgram {
if next_start >= playlist_length {
let json = read_json(&self.config, false, next_start);
- self.json_mod = json.modified.unwrap();
- self.nodes = json.program.into();
+ self.json_mod = json.modified;
+ self.nodes = json.program;
self.index = 0;
}
}
@@ -161,7 +164,7 @@ impl CurrentProgram {
item.duration,
));
self.current_node = handle_list_init(item.clone(), &self.config);
- break
+ break;
}
start_sec += item.out - item.seek;
}
@@ -183,8 +186,8 @@ impl Iterator for CurrentProgram {
let json = read_json(&self.config, false, get_sec() + DUMMY_LEN);
if json.current_file.is_some() {
- self.json_mod = json.modified.unwrap();
- self.json_path = Some(json.current_file.unwrap());
+ self.json_mod = json.modified;
+ self.json_path = json.current_file;
self.nodes = json.program;
self.get_init_clip();
} else {
@@ -252,8 +255,8 @@ impl Iterator for CurrentProgram {
self.json_path = None;
self.nodes = json.program;
} else {
- self.json_mod = json.modified.unwrap();
- self.json_path = Some(json.current_file.unwrap());
+ self.json_mod = json.modified;
+ self.json_path = json.current_file;
self.nodes = json.program;
}