lib/ignore: Centralize handling of temporary filenames (fixes #3899)

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3901
LGTM: calmh, AudriusButkevicius
This commit is contained in:
Simon Frei
2017-01-17 07:33:48 +00:00
committed by Audrius Butkevicius
parent 929a4d0c0c
commit dbb3a34887
7 changed files with 60 additions and 66 deletions
+16
View File
@@ -249,6 +249,22 @@ func (m *Matcher) clean(d time.Duration) {
}
}
// ShouldIgnore returns true when a file is temporary, internal or ignored
func (m *Matcher) ShouldIgnore(filename string) bool {
switch {
case IsTemporary(filename):
return true
case IsInternal(filename):
return true
case m.Match(filename).IsIgnored():
return true
}
return false
}
func hashPatterns(patterns []Pattern) string {
h := md5.New()
for _, pat := range patterns {