Skip to content

Commit

Permalink
Filter only to create and write events on watching UI config
Browse files Browse the repository at this point in the history
Signed-off-by: Ruben Vargas <[email protected]>
  • Loading branch information
rubenvp8510 committed May 20, 2020
1 parent e46f873 commit f49d891
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions cmd/query/app/static_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,17 @@ func (sH *StaticAssetsHandler) watch() {
}
continue
}
if event.Op&fsnotify.Write == fsnotify.Write || event.Op&fsnotify.Create == fsnotify.Create {
// 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))

// 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))
}

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)
}

sH.indexHTML.Store(content)
case err, ok := <-watcher.Errors:
if !ok {
return
Expand Down

0 comments on commit f49d891

Please sign in to comment.