From ee4003f4f1504fe3ad5c2ae54b0350821a3d9d82 Mon Sep 17 00:00:00 2001 From: Dave Date: Sat, 31 Aug 2024 12:56:07 +0200 Subject: [PATCH] Update gitignore and notify only on create (write was being spammed) --- .gitignore | 7 +++++++ go.mod | 2 +- watcher.go | 4 +++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index ba49162..105c52d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,9 @@ test main.log +vendor +.env +folder_mail_notifier.te +folder_mail_notifier.pp +folder-mail-notifier +my-notifier.pp +my-notifier.te diff --git a/go.mod b/go.mod index 316b29c..952c631 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module folder-mail-notifier -go 1.23.0 +go 1.22.0 require ( github.com/joho/godotenv v1.5.1 diff --git a/watcher.go b/watcher.go index 0ab34b3..759e192 100644 --- a/watcher.go +++ b/watcher.go @@ -23,7 +23,9 @@ func WatchRecursively(root string, changeHandler func(fsnotify.Event)) error { if !ok { return } - changeHandler(event) + if fsnotify.Create == event.Op { + changeHandler(event) + } case err, ok := <-watcher.Errors: if !ok { return