dirlist: prevent race condition on accessing uiconfig

Prevent a race condition when accessing UI Config maps

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
Tim Culverhouse 2022-09-26 18:26:35 -05:00 committed by Robin Jarry
parent 4e84df4a28
commit 83136234a4

View file

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