aboutsummaryrefslogtreecommitdiff
path: root/internal/watcher/watch.go
diff options
context:
space:
mode:
authorRanXom <saiyedshizain@gmail.com>2026-07-14 12:35:51 +0530
committerRanXom <saiyedshizain@gmail.com>2026-07-14 12:35:51 +0530
commitd2c0c970f690d52ee3675f377a5eebc22f84afab (patch)
tree100d08c4ac01c98f70801c633aa2a95690cc1592 /internal/watcher/watch.go
parentbd0b89ab49806b976eb0d50dd6f79afdec8b7d11 (diff)
downloadgalleryd-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.go26
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)
+ })
+}