From 7f829f0159f05418c4cbb8b65d33324f9c09ba9f Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Sat, 29 Nov 2014 22:29:49 +0100 Subject: [PATCH] Data race: broken locking on model.folderIgnores --- internal/model/model.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/internal/model/model.go b/internal/model/model.go index 6564bdaa2..efe16bb86 100644 --- a/internal/model/model.go +++ b/internal/model/model.go @@ -779,10 +779,12 @@ func (m *Model) GetIgnores(folder string) ([]string, []string, error) { lines = append(lines, strings.TrimSpace(scanner.Text())) } + m.fmut.RLock() var patterns []string if matcher := m.folderIgnores[folder]; matcher != nil { patterns = matcher.Patterns() } + m.fmut.RUnlock() return lines, patterns, nil } @@ -1050,7 +1052,7 @@ func (m *Model) ScanFolderSub(folder, sub string) error { return errors.New("invalid subpath") } - m.fmut.RLock() + m.fmut.Lock() fs, ok := m.folderFiles[folder] dir := m.folderCfgs[folder].Path @@ -1066,7 +1068,8 @@ func (m *Model) ScanFolderSub(folder, sub string) error { CurrentFiler: cFiler{m, folder}, IgnorePerms: m.folderCfgs[folder].IgnorePerms, } - m.fmut.RUnlock() + m.fmut.Unlock() + if !ok { return errors.New("no such folder") }