releaseDirLocked decrements the refcount for dir and removes the watch when no remaining file points at it. Callers must hold cw.mu.
(dir string)
| 196 | // watch when no remaining file points at it. Callers must hold |
| 197 | // cw.mu. |
| 198 | func (cw *configWatcher) releaseDirLocked(dir string) { |
| 199 | cw.dirs[dir]-- |
| 200 | if cw.dirs[dir] > 0 { |
| 201 | return |
| 202 | } |
| 203 | delete(cw.dirs, dir) |
| 204 | if err := cw.watcher.Remove(dir); err != nil { |
| 205 | // Removal can fail when the directory no longer exists; |
| 206 | // fsnotify already dropped the watch, so this is benign. |
| 207 | cw.logger.Debug(context.Background(), |
| 208 | "failed to remove config dir watch", |
| 209 | slog.F("dir", dir), slog.Error(err)) |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | // run is the watcher loop. It exits when the underlying |
| 214 | // fsnotify.Watcher closes its channels or Close is called. |
no test coverage detected