MCPcopy Create free account
hub / github.com/MiniCodeMonkey/chief / processEvents

Method processEvents

internal/prd/watcher.go:94–125  ·  view source on GitHub ↗

processEvents processes filesystem events and loads the PRD when it changes.

()

Source from the content-addressed store, hash-verified

92
93// processEvents processes filesystem events and loads the PRD when it changes.
94func (w *Watcher) processEvents() {
95 for {
96 select {
97 case <-w.done:
98 close(w.events)
99 return
100
101 case event, ok := <-w.watcher.Events:
102 if !ok {
103 return
104 }
105
106 // Only react to write and create events
107 if event.Op&(fsnotify.Write|fsnotify.Create) != 0 {
108 w.handleFileChange()
109 }
110
111 // Handle file removal - try to re-watch
112 if event.Op&fsnotify.Remove != 0 {
113 w.events <- WatcherEvent{Error: errors.New("prd.md was removed")}
114 // Try to re-add the watch (file might be re-created)
115 _ = w.watcher.Add(w.path)
116 }
117
118 case err, ok := <-w.watcher.Errors:
119 if !ok {
120 return
121 }
122 w.events <- WatcherEvent{Error: err}
123 }
124 }
125}
126
127// handleFileChange loads the PRD and sends an event if it changed.
128func (w *Watcher) handleFileChange() {

Callers 1

StartMethod · 0.95

Calls 1

handleFileChangeMethod · 0.95

Tested by

no test coverage detected