Merge pull request #122 from Bobo1239/fix_cooldown

Fix watch event cooldown
This commit is contained in:
Mathieu David 2016-03-19 19:40:58 +01:00
commit c5752620d7

View file

@ -170,7 +170,7 @@ fn watch(args: &ArgMatches) -> Result<(), Box<Error>> {
// do nothing if book.json is not found // do nothing if book.json is not found
} }
let previous_time = time::get_time().sec; let mut previous_time = time::get_time();
crossbeam::scope(|scope| { crossbeam::scope(|scope| {
loop { loop {
@ -178,8 +178,11 @@ fn watch(args: &ArgMatches) -> Result<(), Box<Error>> {
Ok(event) => { Ok(event) => {
// Skip the event if an event has already been issued in the last second // Skip the event if an event has already been issued in the last second
if time::get_time().sec - previous_time < 1 { let time = time::get_time();
if time - previous_time < time::Duration::seconds(1) {
continue; continue;
} else {
previous_time = time;
} }
if let Some(path) = event.path { if let Some(path) = event.path {