mirror of
https://github.com/restic/restic.git
synced 2026-05-21 09:35:23 +00:00
Don't lower case case-insensitive patterns in place
This commit is contained in:
@@ -39,11 +39,12 @@ func RejectByPattern(patterns []string, warnf func(msg string, args ...interface
|
||||
|
||||
// RejectByInsensitivePattern is like RejectByPattern but case insensitive.
|
||||
func RejectByInsensitivePattern(patterns []string, warnf func(msg string, args ...interface{})) RejectByNameFunc {
|
||||
lowerPatterns := make([]string, len(patterns))
|
||||
for index, path := range patterns {
|
||||
patterns[index] = strings.ToLower(path)
|
||||
lowerPatterns[index] = strings.ToLower(path)
|
||||
}
|
||||
|
||||
rejFunc := RejectByPattern(patterns, warnf)
|
||||
rejFunc := RejectByPattern(lowerPatterns, warnf)
|
||||
return func(item string) bool {
|
||||
return rejFunc(strings.ToLower(item))
|
||||
}
|
||||
|
||||
@@ -92,11 +92,12 @@ func IncludeByPattern(patterns []string, warnf func(msg string, args ...interfac
|
||||
// IncludeByInsensitivePattern returns a IncludeByNameFunc which includes files that match
|
||||
// one of the patterns, ignoring the casing of the filenames.
|
||||
func IncludeByInsensitivePattern(patterns []string, warnf func(msg string, args ...interface{})) IncludeByNameFunc {
|
||||
lowerPatterns := make([]string, len(patterns))
|
||||
for index, path := range patterns {
|
||||
patterns[index] = strings.ToLower(path)
|
||||
lowerPatterns[index] = strings.ToLower(path)
|
||||
}
|
||||
|
||||
includeFunc := IncludeByPattern(patterns, warnf)
|
||||
includeFunc := IncludeByPattern(lowerPatterns, warnf)
|
||||
return func(item string) (matched bool, childMayMatch bool) {
|
||||
return includeFunc(strings.ToLower(item))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user