Skip to content

Commit

Permalink
Merge pull request rust-lang#122 from Bobo1239/fix_cooldown
Browse files Browse the repository at this point in the history
Fix watch event cooldown
  • Loading branch information
azerupi committed Mar 19, 2016
2 parents 0c93599 + 7f3a6c8 commit c575262
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/bin/mdbook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,19 @@ fn watch(args: &ArgMatches) -> Result<(), Box<Error>> {
// 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| {
loop {
match rx.recv() {
Ok(event) => {

// 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;
} else {
previous_time = time;
}

if let Some(path) = event.path {
Expand Down

0 comments on commit c575262

Please sign in to comment.