@@ -22,7 +22,7 @@ import (
2222type watcher struct {
2323 sessions []C.uintptr_t
2424 callback func ()
25- trigger chan struct {}
25+ trigger chan string
2626 stop chan struct {}
2727}
2828
@@ -105,7 +105,7 @@ func retryWatching(watchPattern *watchPattern) {
105105}
106106
107107func (w * watcher ) startWatching (filePatterns []string ) error {
108- w .trigger = make (chan struct {} )
108+ w .trigger = make (chan string )
109109 w .stop = make (chan struct {})
110110 w .sessions = make ([]C.uintptr_t , len (filePatterns ))
111111 watchPatterns , err := parseFilePatterns (filePatterns )
@@ -166,37 +166,38 @@ func handleWatcherEvent(watchPattern *watchPattern, path string, associatedPath
166166 }
167167
168168 if watchPattern .allowReload (path , eventType , pathType ) {
169- watchPattern .trigger <- struct {}{}
169+ watchPattern .trigger <- path
170170 return
171171 }
172172
173173 // some editors create temporary files and never actually modify the original file
174174 // so we need to also check the associated path of an event
175175 // see https://github.com/dunglas/frankenphp/issues/1375
176176 if associatedPath != "" && watchPattern .allowReload (associatedPath , eventType , pathType ) {
177- watchPattern .trigger <- struct {}{}
177+ watchPattern .trigger <- associatedPath
178178 }
179179}
180180
181- func listenForFileEvents (triggerWatcher chan struct {} , stopWatcher chan struct {}) {
181+ func listenForFileEvents (triggerWatcher chan string , stopWatcher chan struct {}) {
182182 timer := time .NewTimer (debounceDuration )
183183 timer .Stop ()
184+ lastChangedFile := ""
184185 defer timer .Stop ()
185186 for {
186187 select {
187188 case <- stopWatcher :
188189 break
189- case <- triggerWatcher :
190+ case lastChangedFile = <- triggerWatcher :
190191 timer .Reset (debounceDuration )
191192 case <- timer .C :
192193 timer .Stop ()
194+ logger .Info ("filesystem change detected" , zap .String ("file" , lastChangedFile ))
193195 scheduleReload ()
194196 }
195197 }
196198}
197199
198200func scheduleReload () {
199- logger .Info ("filesystem change detected" )
200201 reloadWaitGroup .Add (1 )
201202 activeWatcher .callback ()
202203 reloadWaitGroup .Done ()
0 commit comments