MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / Watcher

Struct Watcher

apps/server/internal/watcher/watcher.go:24–36  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

22// events to any subscribed channels. Mirrors the chokidar-based
23// watcher in src/main/watcher.ts.
24type 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
38func Start(root string) (*Watcher, error) {
39 fsw, err := fsnotify.NewWatcher()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected