diff --git a/cmd/query/app/static_handler.go b/cmd/query/app/static_handler.go index 472283931cf..d1a89ce4c98 100644 --- a/cmd/query/app/static_handler.go +++ b/cmd/query/app/static_handler.go @@ -130,28 +130,21 @@ func (sH *StaticAssetsHandler) configListener(watcher *fsnotify.Watcher) { for { select { case event := <-watcher.Events: - if event.Op&fsnotify.Remove == fsnotify.Remove { - // this might be related to a file inside the dir, so, just log a warn if this is about the file we care about - // otherwise, just ignore the event - if event.Name == sH.options.UIConfigPath { - sH.options.Logger.Warn("the UI config file has been removed, using the last known version") - } + // Ignore if the event filename is not the UI configuration or if it is a chmod event. + if filepath.Base(event.Name) != filepath.Base(sH.options.UIConfigPath) || event.Op&fsnotify.Chmod == fsnotify.Chmod { continue } - if event.Op&fsnotify.Write != fsnotify.Write && event.Op&fsnotify.Create != fsnotify.Create { + if event.Op&fsnotify.Remove == fsnotify.Remove { + sH.options.Logger.Warn("the UI config file has been removed, using the last known version") continue } - if event.Name == sH.options.UIConfigPath { - // this will catch events for all files inside the same directory, which is OK if we don't have many changes - sH.options.Logger.Info("reloading UI config", zap.String("filename", sH.options.UIConfigPath)) - - content, err := loadIndexBytes(sH.assetsFS.Open, sH.options) - if err != nil { - sH.options.Logger.Error("error while reloading the UI config", zap.Error(err)) - } - - sH.indexHTML.Store(content) + // this will catch events for all files inside the same directory, which is OK if we don't have many changes + sH.options.Logger.Info("reloading UI config", zap.String("filename", sH.options.UIConfigPath)) + content, err := loadIndexBytes(sH.assetsFS.Open, sH.options) + if err != nil { + sH.options.Logger.Error("error while reloading the UI config", zap.Error(err)) } + sH.indexHTML.Store(content) case err, ok := <-watcher.Errors: if !ok { return