@@ -130,28 +130,22 @@ func (sH *StaticAssetsHandler) configListener(watcher *fsnotify.Watcher) {
130130 for {
131131 select {
132132 case event := <- watcher .Events :
133- if event .Op & fsnotify .Remove == fsnotify .Remove {
134- // this might be related to a file inside the dir, so, just log a warn if this is about the file we care about
135- // otherwise, just ignore the event
136- if event .Name == sH .options .UIConfigPath {
137- sH .options .Logger .Warn ("the UI config file has been removed, using the last known version" )
138- }
133+ eventFileName := filepath .Base (event .Name )
134+ // Ignore if the event filename is not the UI configuration or if it is a chmod event.
135+ if eventFileName != filepath .Base (sH .options .UIConfigPath ) || event .Op & fsnotify .Chmod == fsnotify .Chmod {
139136 continue
140137 }
141- if event .Op & fsnotify .Write != fsnotify .Write && event .Op & fsnotify .Create != fsnotify .Create {
138+ if event .Op & fsnotify .Remove == fsnotify .Remove {
139+ sH .options .Logger .Warn ("the UI config file has been removed, using the last known version" )
142140 continue
143141 }
144- if event .Name == sH .options .UIConfigPath {
145- // this will catch events for all files inside the same directory, which is OK if we don't have many changes
146- sH .options .Logger .Info ("reloading UI config" , zap .String ("filename" , sH .options .UIConfigPath ))
147-
148- content , err := loadIndexBytes (sH .assetsFS .Open , sH .options )
149- if err != nil {
150- sH .options .Logger .Error ("error while reloading the UI config" , zap .Error (err ))
151- }
152-
153- sH .indexHTML .Store (content )
142+ // this will catch events for all files inside the same directory, which is OK if we don't have many changes
143+ sH .options .Logger .Info ("reloading UI config" , zap .String ("filename" , sH .options .UIConfigPath ))
144+ content , err := loadIndexBytes (sH .assetsFS .Open , sH .options )
145+ if err != nil {
146+ sH .options .Logger .Error ("error while reloading the UI config" , zap .Error (err ))
154147 }
148+ sH .indexHTML .Store (content )
155149 case err , ok := <- watcher .Errors :
156150 if ! ok {
157151 return
0 commit comments