From 96cdd967f054fb8bbc9575ecebbef2cc5a68a14f Mon Sep 17 00:00:00 2001 From: Martin Polden Date: Sun, 12 Sep 2021 10:16:00 +0200 Subject: watcher: Use platform-specific flags on Linux --- watcher/watcher.go | 2 -- watcher/watcher_linux.go | 8 ++++++++ watcher/watcher_notlinux.go | 7 +++++++ 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 watcher/watcher_linux.go create mode 100644 watcher/watcher_notlinux.go 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 -- cgit v1.2.3