diff options
| author | RanXom <saiyedshizain@gmail.com> | 2026-07-14 12:35:51 +0530 |
|---|---|---|
| committer | RanXom <saiyedshizain@gmail.com> | 2026-07-14 12:35:51 +0530 |
| commit | d2c0c970f690d52ee3675f377a5eebc22f84afab (patch) | |
| tree | 100d08c4ac01c98f70801c633aa2a95690cc1592 /internal/watcher/watch.go | |
| parent | bd0b89ab49806b976eb0d50dd6f79afdec8b7d11 (diff) | |
| download | galleryd-d2c0c970f690d52ee3675f377a5eebc22f84afab.tar.xz galleryd-d2c0c970f690d52ee3675f377a5eebc22f84afab.zip | |
feat(watcher): watch newly created directories
Diffstat (limited to 'internal/watcher/watch.go')
| -rw-r--r-- | internal/watcher/watch.go | 26 |
1 files changed, 26 insertions, 0 deletions
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) + }) +} |