aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2021-09-10 19:21:46 +0200
committerMartin Polden <mpolden@mpolden.no>2021-09-10 19:21:46 +0200
commit44d4b2545bd472bbe0abd3eab286417b9f795cf0 (patch)
tree8d82dea6675ada9f02f82b7560a26a8f6d423523
parentb15be314c1481bb5325ce6e3264451df76d2bd69 (diff)
watcher: Watch for renames
-rw-r--r--watcher/watcher.go4
-rw-r--r--watcher/watcher_linux.go10
-rw-r--r--watcher/watcher_notlinux.go7
3 files changed, 3 insertions, 18 deletions
diff --git a/watcher/watcher.go b/watcher/watcher.go
index cc3ef79..0d62030 100644
--- a/watcher/watcher.go
+++ b/watcher/watcher.go
@@ -16,6 +16,8 @@ import (
"github.com/rjeczalik/notify"
)
+const notifyFlag = notify.Write | notify.Rename
+
type Handler interface {
Handle(filename, postCommand string, remove bool) error
}
@@ -66,7 +68,7 @@ func (w *Watcher) handle(name string) error {
func (w *Watcher) watch() {
for _, path := range w.config.Paths {
rpath := filepath.Join(path.Name, "...")
- if err := notify.Watch(rpath, w.events, writeFlag); err != nil {
+ if err := notify.Watch(rpath, w.events, notifyFlag); err != nil {
w.log.Printf("failed to watch %s: %s", rpath, err)
} else {
w.log.Printf("watching %s recursively", path.Name)
diff --git a/watcher/watcher_linux.go b/watcher/watcher_linux.go
deleted file mode 100644
index f713d55..0000000
--- a/watcher/watcher_linux.go
+++ /dev/null
@@ -1,10 +0,0 @@
-// +build linux
-
-package watcher
-
-import (
- "github.com/rjeczalik/notify"
-)
-
-// Watch IN_CLOSE_WRITE events on Linux to reduce the number events received
-const writeFlag = notify.InCloseWrite
diff --git a/watcher/watcher_notlinux.go b/watcher/watcher_notlinux.go
deleted file mode 100644
index 05accc3..0000000
--- a/watcher/watcher_notlinux.go
+++ /dev/null
@@ -1,7 +0,0 @@
-// +build !linux
-
-package watcher
-
-import "github.com/rjeczalik/notify"
-
-const writeFlag = notify.Write