mirror of
https://github.com/octoleo/restic.git
synced 2024-11-22 04:45:15 +00:00
filter: Fix crash for '**' pattern
This commit is contained in:
parent
6d8ceefd67
commit
55bea6e7a6
7
changelog/unreleased/issue-3380
Normal file
7
changelog/unreleased/issue-3380
Normal file
@ -0,0 +1,7 @@
|
||||
Bugfix: Fix crash of `backup --exclude='**'`
|
||||
|
||||
The exclude filter '**', which excludes all files, caused restic to crash. This
|
||||
has been fixed.
|
||||
|
||||
https://github.com/restic/restic/issues/3380
|
||||
https://github.com/restic/restic/pull/3393
|
@ -166,6 +166,11 @@ func match(patterns Pattern, strs []string) (matched bool, err error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// an empty pattern never matches a non-empty path
|
||||
if len(patterns) == 0 {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
if len(patterns) <= len(strs) {
|
||||
minOffset := 0
|
||||
maxOffset := len(strs) - len(patterns)
|
||||
|
@ -23,6 +23,7 @@ var matchTests = []struct {
|
||||
{"*.go", "/foo/bar/test.go", true},
|
||||
{"*.c", "/foo/bar/test.go", false},
|
||||
{"*", "/foo/bar/test.go", true},
|
||||
{"**", "/foo/bar/test.go", true},
|
||||
{"foo*", "/foo/bar/test.go", true},
|
||||
{"bar*", "/foo/bar/test.go", true},
|
||||
{"/bar*", "/foo/bar/test.go", false},
|
||||
|
Loading…
Reference in New Issue
Block a user