Skip to content

Commit

Permalink
Merge pull request #12 from arp242/fix
Browse files Browse the repository at this point in the history
Fix watching additional paths, correct events on Linux
  • Loading branch information
ripexz authored Apr 12, 2022
2 parents 9239a69 + b28a549 commit a785289
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions reload.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"math"
"os"
"path/filepath"
"runtime"
"strings"
"syscall"
"time"
Expand Down Expand Up @@ -101,7 +100,7 @@ func Do(log func(string, ...interface{}), additional ...dir) error {
a.path)
}

a.path = path
additional[i].path = path
dirs[i+1] = path
timers[path] = stoppedTimer(a.cb)
}
Expand All @@ -115,19 +114,7 @@ func Do(log func(string, ...interface{}), additional ...dir) error {
log("reload error: %v", err)
}
case event := <-watcher.Events:
// Ensure that we use the correct events, as they are not uniform accross
// platforms. See https://github.com/fsnotify/fsnotify/issues/74
var trigger bool
switch runtime.GOOS {
case "darwin", "freebsd", "openbsd", "netbsd", "dragonfly":
trigger = event.Op&fsnotify.Create == fsnotify.Create
case "linux":
trigger = event.Op&fsnotify.Write == fsnotify.Write
default:
trigger = event.Op&fsnotify.Create == fsnotify.Create
log("reload: untested GOOS %q; this package may not work correctly", runtime.GOOS)
}

trigger := (event.Op&fsnotify.Write == fsnotify.Write) || (event.Op&fsnotify.Create == fsnotify.Create)
if !trigger {
continue
}
Expand Down

0 comments on commit a785289

Please sign in to comment.