Watcher recursively watches the vault root and fans out change events to any subscribed channels. Mirrors the chokidar-based watcher in src/main/watcher.ts.
| 22 | // events to any subscribed channels. Mirrors the chokidar-based |
| 23 | // watcher in src/main/watcher.ts. |
| 24 | type Watcher struct { |
| 25 | root string |
| 26 | fs *fsnotify.Watcher |
| 27 | mu sync.Mutex |
| 28 | subs map[chan vault.ChangeEvent]struct{} |
| 29 | closed bool |
| 30 | stopCh chan struct{} |
| 31 | // dirs tracks the absolute paths we believe are directories, so a |
| 32 | // remove/rename event (which can't be os.Stat'd) can still be recognized |
| 33 | // as a folder change. Only touched from the single loop goroutine (and |
| 34 | // Start, before the loop begins), so it needs no separate lock. |
| 35 | dirs map[string]struct{} |
| 36 | } |
| 37 | |
| 38 | func Start(root string) (*Watcher, error) { |
| 39 | fsw, err := fsnotify.NewWatcher() |
nothing calls this directly
no outgoing calls
no test coverage detected