Merge pull request #1720 from AudriusButkevicius/ignores

Matcher is always there
This commit is contained in:
Jakob Borg 2015-04-28 11:35:12 +02:00
commit 4c6eb137da
3 changed files with 12 additions and 7 deletions

View File

@ -95,6 +95,10 @@ func (m *Matcher) Parse(r io.Reader, file string) error {
} }
func (m *Matcher) Match(file string) (result bool) { func (m *Matcher) Match(file string) (result bool) {
if m == nil {
return false
}
m.mut.Lock() m.mut.Lock()
defer m.mut.Unlock() defer m.mut.Unlock()
@ -128,6 +132,10 @@ func (m *Matcher) Match(file string) (result bool) {
// Patterns return a list of the loaded regexp patterns, as strings // Patterns return a list of the loaded regexp patterns, as strings
func (m *Matcher) Patterns() []string { func (m *Matcher) Patterns() []string {
if m == nil {
return nil
}
m.mut.Lock() m.mut.Lock()
defer m.mut.Unlock() defer m.mut.Unlock()

View File

@ -858,10 +858,7 @@ func (m *Model) GetIgnores(folder string) ([]string, []string, error) {
} }
m.fmut.RLock() m.fmut.RLock()
var patterns []string patterns := m.folderIgnores[folder].Patterns()
if matcher := m.folderIgnores[folder]; matcher != nil {
patterns = matcher.Patterns()
}
m.fmut.RUnlock() m.fmut.RUnlock()
return lines, patterns, nil return lines, patterns, nil
@ -1010,7 +1007,7 @@ func sendIndexTo(initial bool, minLocalVer int64, conn protocol.Connection, fold
maxLocalVer = f.LocalVersion maxLocalVer = f.LocalVersion
} }
if (ignores != nil && ignores.Match(f.Name)) || symlinkInvalid(f.IsSymlink()) { if ignores.Match(f.Name) || symlinkInvalid(f.IsSymlink()) {
if debug { if debug {
l.Debugln("not sending update for ignored/unsupported symlink", f) l.Debugln("not sending update for ignored/unsupported symlink", f)
} }
@ -1281,7 +1278,7 @@ nextSub:
batch = batch[:0] batch = batch[:0]
} }
if (ignores != nil && ignores.Match(f.Name)) || symlinkInvalid(f.IsSymlink()) { if ignores.Match(f.Name) || symlinkInvalid(f.IsSymlink()) {
// File has been ignored or an unsupported symlink. Set invalid bit. // File has been ignored or an unsupported symlink. Set invalid bit.
if debug { if debug {
l.Debugln("setting invalid bit on ignored", f) l.Debugln("setting invalid bit on ignored", f)

View File

@ -158,7 +158,7 @@ func (w *Walker) walkAndHashFiles(fchan chan protocol.FileInfo) filepath.WalkFun
} }
if sn := filepath.Base(rn); sn == ".stignore" || sn == ".stfolder" || if sn := filepath.Base(rn); sn == ".stignore" || sn == ".stfolder" ||
strings.HasPrefix(rn, ".stversions") || (w.Matcher != nil && w.Matcher.Match(rn)) { strings.HasPrefix(rn, ".stversions") || w.Matcher.Match(rn) {
// An ignored file // An ignored file
if debug { if debug {
l.Debugln("ignored:", rn) l.Debugln("ignored:", rn)