Skip to content

Commit

Permalink
lib/model: Fix race in GetIgnores (fixes syncthing#4300)
Browse files Browse the repository at this point in the history
In addition this function returned an error when .stignore file was not
present, which is perfectly valid. Also removed inconsistent nil check in
ignores.go (only relevant for tests) and adjusted walk.go to do what it says
in comments (check if Matcher is nil) to prevent nil deref in tests.

Originally reported in:
https://forum.syncthing.net/t/reason-for-panic-maybe-too-little-ram/10346

Regression from syncthing#3996

GitHub-Pull-Request: syncthing#4301
  • Loading branch information
imsodin authored and AudriusButkevicius committed Aug 12, 2017
1 parent 77578e8 commit ab8c2fb
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -1245,16 +1245,15 @@ func (m *Model) ConnectedTo(deviceID protocol.DeviceID) bool {

func (m *Model) GetIgnores(folder string) ([]string, []string, error) {
m.fmut.RLock()
defer m.fmut.RUnlock()

cfg, ok := m.folderCfgs[folder]
m.fmut.RUnlock()
if ok {
if !cfg.HasMarker() {
return nil, nil, fmt.Errorf("Folder %s stopped", folder)
}

m.fmut.RLock()
ignores := m.folderIgnores[folder]
m.fmut.RUnlock()

return ignores.Lines(), ignores.Patterns(), nil
}
Expand Down

0 comments on commit ab8c2fb

Please sign in to comment.