Skip to content

Commit

Permalink
cmd: wait 0.1 seconds before processing watched file change, fixes #372
Browse files Browse the repository at this point in the history
  • Loading branch information
tdewolff committed Mar 9, 2021
1 parent 9b77a7e commit 273dcd6
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions cmd/minify/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ func (w *Watcher) Run() chan string {
} else if info.Mode().IsRegular() {
if event.Op&fsnotify.Write == fsnotify.Write {
if t, ok := changetimes[event.Name]; !ok || 100*time.Millisecond < time.Now().Sub(t) {
time.Sleep(100 * time.Millisecond) // wait to make sure write is finished
files <- event.Name
changetimes[event.Name] = time.Now()
}
Expand Down

0 comments on commit 273dcd6

Please sign in to comment.