aboutsummaryrefslogtreecommitdiff
path: root/internal/watcher/watch.go
diff options
context:
space:
mode:
authorSaiyed Shizain <saiyedshizain@gmail.com>2026-07-17 11:10:53 +0530
committerGitHub <noreply@github.com>2026-07-17 11:10:53 +0530
commit6afb80ab754da137939dd523ee419818026f9fb5 (patch)
treef9f94ec69ac87abe8060cefca8708572bc13bdd6 /internal/watcher/watch.go
parentbcfb199ac8e5399e1a92cfbbc28af3674f80959d (diff)
parent5ae787be3d1d9de3355f8b5662fea857204e693c (diff)
downloadgalleryd-6afb80ab754da137939dd523ee419818026f9fb5.tar.xz
galleryd-6afb80ab754da137939dd523ee419818026f9fb5.zip
Merge pull request #11 from RanXom/feat/live-gallery
Feat/live-gallery: live gallery with automatic filesystem reloads
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)
+ })
+}