From 83136234a4e93b50d1079765bb4bb04d3322a4c7 Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Mon, 26 Sep 2022 18:26:35 -0500 Subject: [PATCH] dirlist: prevent race condition on accessing uiconfig Prevent a race condition when accessing UI Config maps Signed-off-by: Tim Culverhouse Acked-by: Robin Jarry --- widgets/dirlist.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/widgets/dirlist.go b/widgets/dirlist.go index 643be44..0f86a08 100644 --- a/widgets/dirlist.go +++ b/widgets/dirlist.go @@ -8,6 +8,7 @@ import ( "regexp" "sort" "strings" + "sync" "time" "github.com/gdamore/tcell/v2" @@ -48,6 +49,7 @@ type DirectoryLister interface { type DirectoryList struct { ui.Invalidatable + sync.Mutex Scrollable aercConf *config.AercConfig acctConf *config.AccountConfig @@ -90,6 +92,8 @@ func NewDirectoryList(conf *config.AercConfig, acctConf *config.AccountConfig, } func (dirlist *DirectoryList) UiConfig(dir string) *config.UIConfig { + dirlist.Lock() + defer dirlist.Unlock() if dir == "" { dir = dirlist.Selected() }