mirror of
https://github.com/octoleo/syncthing.git
synced 2025-02-02 11:58:28 +00:00
lib/ignore: Refactor: notMatched should be one of the constants
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3031
This commit is contained in:
parent
abb96802cb
commit
6720906ee5
@ -23,13 +23,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
resultNotMatched Result = 0
|
||||||
resultInclude Result = 1 << iota
|
resultInclude Result = 1 << iota
|
||||||
resultDeletable = 1 << iota
|
resultDeletable = 1 << iota
|
||||||
resultFoldCase = 1 << iota
|
resultFoldCase = 1 << iota
|
||||||
)
|
)
|
||||||
|
|
||||||
var notMatched Result = 0
|
|
||||||
|
|
||||||
type Pattern struct {
|
type Pattern struct {
|
||||||
pattern string
|
pattern string
|
||||||
match glob.Glob
|
match glob.Glob
|
||||||
@ -125,14 +124,14 @@ func (m *Matcher) Parse(r io.Reader, file string) error {
|
|||||||
|
|
||||||
func (m *Matcher) Match(file string) (result Result) {
|
func (m *Matcher) Match(file string) (result Result) {
|
||||||
if m == nil {
|
if m == nil {
|
||||||
return notMatched
|
return resultNotMatched
|
||||||
}
|
}
|
||||||
|
|
||||||
m.mut.Lock()
|
m.mut.Lock()
|
||||||
defer m.mut.Unlock()
|
defer m.mut.Unlock()
|
||||||
|
|
||||||
if len(m.patterns) == 0 {
|
if len(m.patterns) == 0 {
|
||||||
return notMatched
|
return resultNotMatched
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.matches != nil {
|
if m.matches != nil {
|
||||||
@ -166,8 +165,8 @@ func (m *Matcher) Match(file string) (result Result) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default to false.
|
// Default to not matching.
|
||||||
return notMatched
|
return resultNotMatched
|
||||||
}
|
}
|
||||||
|
|
||||||
// Patterns return a list of the loaded patterns, as they've been parsed
|
// Patterns return a list of the loaded patterns, as they've been parsed
|
||||||
|
Loading…
x
Reference in New Issue
Block a user