aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--watcher/watcher.go2
-rw-r--r--watcher/watcher_linux.go8
-rw-r--r--watcher/watcher_notlinux.go7
3 files changed, 15 insertions, 2 deletions
diff --git a/watcher/watcher.go b/watcher/watcher.go
index 8f837e1..93e4f33 100644
--- a/watcher/watcher.go
+++ b/watcher/watcher.go
@@ -15,8 +15,6 @@ import (
"github.com/rjeczalik/notify"
)
-const notifyFlag = notify.Write | notify.Rename
-
type Handler interface {
Handle(filename, postCommand string, remove bool) error
}
diff --git a/watcher/watcher_linux.go b/watcher/watcher_linux.go
new file mode 100644
index 0000000..a7a23cd
--- /dev/null
+++ b/watcher/watcher_linux.go
@@ -0,0 +1,8 @@
+//go:build linux
+
+package watcher
+
+import "github.com/rjeczalik/notify"
+
+// Watch IN_CLOSE_WRITE events on Linux to reduce the number of events to process
+const notifyFlag = notify.InCloseWrite | notify.InMovedFrom
diff --git a/watcher/watcher_notlinux.go b/watcher/watcher_notlinux.go
new file mode 100644
index 0000000..efd7ea8
--- /dev/null
+++ b/watcher/watcher_notlinux.go
@@ -0,0 +1,7 @@
+//go:build !linux
+
+package watcher
+
+import "github.com/rjeczalik/notify"
+
+const notifyFlag = notify.Write | notify.Rename