RemoveRoot stops watching a root and removes it.
(root string)
| 169 | |
| 170 | // RemoveRoot stops watching a root and removes it. |
| 171 | func (e *Engine) RemoveRoot(root string) error { |
| 172 | absRoot, err := filepath.Abs(root) |
| 173 | if err != nil { |
| 174 | return xerrors.Errorf("resolve root: %w", err) |
| 175 | } |
| 176 | e.mu.Lock() |
| 177 | defer e.mu.Unlock() |
| 178 | rs, exists := e.roots[absRoot] |
| 179 | if !exists { |
| 180 | return xerrors.Errorf("root %q not found", absRoot) |
| 181 | } |
| 182 | rs.cancel() |
| 183 | _ = rs.watcher.Close() |
| 184 | delete(e.roots, absRoot) |
| 185 | e.publishSnapshot() |
| 186 | return nil |
| 187 | } |
| 188 | |
| 189 | // Search performs a fuzzy file search across all roots. |
| 190 | func (e *Engine) Search(_ context.Context, query string, opts SearchOptions) ([]Result, error) { |