mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 04:44:37 +03:00
Cache generated regex for each path (#891)
This commit is contained in:
@@ -38,15 +38,20 @@ func excludeFiles(files []string, patterns []string) ([]string, int) {
|
||||
}
|
||||
}
|
||||
|
||||
func matchFileRegex(file string, fileRegexps []*regexp.Regexp) bool {
|
||||
for _, regPattern := range fileRegexps {
|
||||
if regPattern.MatchString(strings.ToLower(file)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func matchFile(file string, patterns []string) bool {
|
||||
if patterns != nil {
|
||||
fileRegexps := generateRegexps(patterns)
|
||||
|
||||
for _, regPattern := range fileRegexps {
|
||||
if regPattern.MatchString(strings.ToLower(file)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return matchFileRegex(file, fileRegexps)
|
||||
}
|
||||
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user