fix fsnotify not fully working (#2258)

mine
Jayson Wang 2023-10-30 03:32:41 +08:00 committed by GitHub
parent 85c0f26158
commit 09719eb16b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 7 deletions

View File

@ -44,10 +44,11 @@ func (c *Configurator) CustomViewsWatcher(ctx context.Context, s synchronizer) e
for { for {
select { select {
case evt := <-w.Events: case evt := <-w.Events:
_ = evt if evt.Name == config.K9sViewConfigFile {
s.QueueUpdateDraw(func() { s.QueueUpdateDraw(func() {
c.RefreshCustomViews() c.RefreshCustomViews()
}) })
}
case err := <-w.Errors: case err := <-w.Errors:
log.Warn().Err(err).Msg("CustomView watcher failed") log.Warn().Err(err).Msg("CustomView watcher failed")
return return
@ -63,7 +64,7 @@ func (c *Configurator) CustomViewsWatcher(ctx context.Context, s synchronizer) e
log.Debug().Msgf("CustomView watching `%s", config.K9sViewConfigFile) log.Debug().Msgf("CustomView watching `%s", config.K9sViewConfigFile)
c.RefreshCustomViews() c.RefreshCustomViews()
return w.Add(config.K9sViewConfigFile) return w.Add(config.K9sHome())
} }
// RefreshCustomViews load view configuration changes. // RefreshCustomViews load view configuration changes.
@ -95,7 +96,7 @@ func (c *Configurator) StylesWatcher(ctx context.Context, s synchronizer) error
for { for {
select { select {
case evt := <-w.Events: case evt := <-w.Events:
if evt.Op != fsnotify.Chmod { if evt.Name == c.skinFile && evt.Op != fsnotify.Chmod {
s.QueueUpdateDraw(func() { s.QueueUpdateDraw(func() {
c.RefreshStyles(c.Config.K9s.CurrentCluster) c.RefreshStyles(c.Config.K9s.CurrentCluster)
}) })
@ -114,7 +115,7 @@ func (c *Configurator) StylesWatcher(ctx context.Context, s synchronizer) error
}() }()
log.Debug().Msgf("SkinWatcher watching `%s", c.skinFile) log.Debug().Msgf("SkinWatcher watching `%s", c.skinFile)
return w.Add(c.skinFile) return w.Add(config.K9sHome())
} }
// BenchConfig location of the benchmarks configuration file. // BenchConfig location of the benchmarks configuration file.