MCPcopy
hub / github.com/docker/compose / watchRecursively

Method watchRecursively

pkg/watch/watcher_naive.go:105–137  ·  view source on GitHub ↗
(dir string)

Source from the content-addressed store, hash-verified

103}
104
105func (d *naiveNotify) watchRecursively(dir string) error {
106 if d.isWatcherRecursive {
107 err := d.add(dir)
108 if err == nil || os.IsNotExist(err) {
109 return nil
110 }
111 return fmt.Errorf("watcher.Add(%q): %w", dir, err)
112 }
113
114 return filepath.WalkDir(dir, func(path string, info fs.DirEntry, err error) error {
115 if err != nil {
116 return err
117 }
118
119 if !info.IsDir() {
120 return nil
121 }
122
123 if d.shouldSkipDir(path) {
124 logrus.Debugf("Ignoring directory and its contents (recursively): %s", path)
125 return filepath.SkipDir
126 }
127
128 err = d.add(path)
129 if err != nil {
130 if os.IsNotExist(err) {
131 return nil
132 }
133 return fmt.Errorf("watcher.Add(%q): %w", path, err)
134 }
135 return nil
136 })
137}
138
139func (d *naiveNotify) Close() error {
140 numberOfWatches.Add(-d.numWatches)

Callers 1

StartMethod · 0.95

Calls 2

addMethod · 0.95
shouldSkipDirMethod · 0.95

Tested by

no test coverage detected