forked from TrueCloudLab/restic
filter: Fix crash for '**' pattern
This commit is contained in:
parent
6d8ceefd67
commit
55bea6e7a6
3 changed files with 13 additions and 0 deletions
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
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// an empty pattern never matches a non-empty path
|
||||||
|
if len(patterns) == 0 {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
if len(patterns) <= len(strs) {
|
if len(patterns) <= len(strs) {
|
||||||
minOffset := 0
|
minOffset := 0
|
||||||
maxOffset := len(strs) - len(patterns)
|
maxOffset := len(strs) - len(patterns)
|
||||||
|
|
|
@ -23,6 +23,7 @@ var matchTests = []struct {
|
||||||
{"*.go", "/foo/bar/test.go", true},
|
{"*.go", "/foo/bar/test.go", true},
|
||||||
{"*.c", "/foo/bar/test.go", false},
|
{"*.c", "/foo/bar/test.go", false},
|
||||||
{"*", "/foo/bar/test.go", true},
|
{"*", "/foo/bar/test.go", true},
|
||||||
|
{"**", "/foo/bar/test.go", true},
|
||||||
{"foo*", "/foo/bar/test.go", true},
|
{"foo*", "/foo/bar/test.go", true},
|
||||||
{"bar*", "/foo/bar/test.go", true},
|
{"bar*", "/foo/bar/test.go", true},
|
||||||
{"/bar*", "/foo/bar/test.go", false},
|
{"/bar*", "/foo/bar/test.go", false},
|
||||||
|
|
Loading…
Reference in a new issue