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

Method Remove

agent/agentcontainers/watcher/watcher.go:94–127  ·  view source on GitHub ↗
(file string)

Source from the content-addressed store, hash-verified

92}
93
94func (f *fsnotifyWatcher) Remove(file string) error {
95 absPath, err := filepath.Abs(file)
96 if err != nil {
97 return xerrors.Errorf("absolute path: %w", err)
98 }
99
100 dir := filepath.Dir(absPath)
101
102 f.mu.Lock()
103 defer f.mu.Unlock()
104
105 // Not watching this file.
106 if f.closed || !f.watchedFiles[absPath] {
107 return nil
108 }
109
110 // Remove the file from our watch list.
111 delete(f.watchedFiles, absPath)
112
113 // Decrement the reference count for this directory.
114 f.watchedDirs[dir]--
115
116 // If no more files in this directory are being watched, stop
117 // watching the directory.
118 if f.watchedDirs[dir] <= 0 {
119 f.watchedDirs[dir] = 0 // Ensure non-negative count.
120 if err := f.Watcher.Remove(dir); err != nil {
121 return xerrors.Errorf("remove directory from watcher: %w", err)
122 }
123 delete(f.watchedDirs, dir)
124 }
125
126 return nil
127}
128
129func (f *fsnotifyWatcher) Next(ctx context.Context) (event *fsnotify.Event, err error) {
130 defer func() {

Callers

nothing calls this directly

Calls 4

RemoveMethod · 0.65
ErrorfMethod · 0.45
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected