forked from TrueCloudLab/restic
restore: accumulate results of multiple pattern checks
addressing review comments
This commit is contained in:
parent
e579dfe72a
commit
3a52176121
1 changed files with 14 additions and 11 deletions
|
@ -150,9 +150,10 @@ func runRestore(ctx context.Context, opts RestoreOptions, gopts GlobalOptions,
|
||||||
}
|
}
|
||||||
|
|
||||||
selectExcludeFilter := func(item string, _ string, node *restic.Node) (selectedForRestore bool, childMayBeSelected bool) {
|
selectExcludeFilter := func(item string, _ string, node *restic.Node) (selectedForRestore bool, childMayBeSelected bool) {
|
||||||
|
matched := false
|
||||||
for _, rejectFn := range excludePatternFns {
|
for _, rejectFn := range excludePatternFns {
|
||||||
matched := rejectFn(item)
|
matched = matched || rejectFn(item)
|
||||||
|
}
|
||||||
// An exclude filter is basically a 'wildcard but foo',
|
// An exclude filter is basically a 'wildcard but foo',
|
||||||
// so even if a childMayMatch, other children of a dir may not,
|
// so even if a childMayMatch, other children of a dir may not,
|
||||||
// therefore childMayMatch does not matter, but we should not go down
|
// therefore childMayMatch does not matter, but we should not go down
|
||||||
|
@ -162,12 +163,14 @@ func runRestore(ctx context.Context, opts RestoreOptions, gopts GlobalOptions,
|
||||||
|
|
||||||
return selectedForRestore, childMayBeSelected
|
return selectedForRestore, childMayBeSelected
|
||||||
}
|
}
|
||||||
return selectedForRestore, childMayBeSelected
|
|
||||||
}
|
|
||||||
|
|
||||||
selectIncludeFilter := func(item string, _ string, node *restic.Node) (selectedForRestore bool, childMayBeSelected bool) {
|
selectIncludeFilter := func(item string, _ string, node *restic.Node) (selectedForRestore bool, childMayBeSelected bool) {
|
||||||
|
selectedForRestore = false
|
||||||
|
childMayBeSelected = false
|
||||||
for _, includeFn := range includePatternFns {
|
for _, includeFn := range includePatternFns {
|
||||||
selectedForRestore, childMayBeSelected = includeFn(item)
|
matched, childMayMatch := includeFn(item)
|
||||||
|
selectedForRestore = selectedForRestore || matched
|
||||||
|
childMayBeSelected = childMayBeSelected || childMayMatch
|
||||||
}
|
}
|
||||||
|
|
||||||
childMayBeSelected = childMayBeSelected && node.Type == "dir"
|
childMayBeSelected = childMayBeSelected && node.Type == "dir"
|
||||||
|
|
Loading…
Reference in a new issue