MCPcopy Create free account
hub / github.com/coder/coder / releaseDirLocked

Method releaseDirLocked

agent/x/agentmcp/configwatcher.go:198–211  ·  view source on GitHub ↗

releaseDirLocked decrements the refcount for dir and removes the watch when no remaining file points at it. Callers must hold cw.mu.

(dir string)

Source from the content-addressed store, hash-verified

196// watch when no remaining file points at it. Callers must hold
197// cw.mu.
198func (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.

Callers 2

SyncMethod · 0.95
handleEventMethod · 0.95

Calls 2

RemoveMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected