From d2c0c970f690d52ee3675f377a5eebc22f84afab Mon Sep 17 00:00:00 2001 From: RanXom Date: Tue, 14 Jul 2026 12:35:51 +0530 Subject: feat(watcher): watch newly created directories --- internal/watcher/watch.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 internal/watcher/watch.go (limited to 'internal/watcher/watch.go') diff --git a/internal/watcher/watch.go b/internal/watcher/watch.go new file mode 100644 index 0000000..95146ce --- /dev/null +++ b/internal/watcher/watch.go @@ -0,0 +1,26 @@ +package watcher + +import ( + "io/fs" + "path/filepath" + + "github.com/fsnotify/fsnotify" +) + +// watchTree recursively watches root and all of its subdirectories. +func watchTree( + w *fsnotify.Watcher, + root string, +) error { + return filepath.WalkDir(root, func(path string, d fs.DirEntry, err error) error { + if err != nil { + return err + } + + if !d.IsDir() { + return nil + } + + return w.Add(path) + }) +} -- cgit v1.2.3