mirror of
https://github.com/restic/restic.git
synced 2025-10-27 14:28:54 +00:00
Smarter filter when children won't match
This improves restore performance by several orders of magniture by not going through the whole tree recursively when we can anticipate that no match will ever occur.
This commit is contained in:
@@ -417,7 +417,7 @@ func runBackup(opts BackupOptions, gopts GlobalOptions, args []string) error {
|
||||
}
|
||||
|
||||
selectFilter := func(item string, fi os.FileInfo) bool {
|
||||
matched, err := filter.List(opts.Excludes, item)
|
||||
matched, _, err := filter.List(opts.Excludes, item)
|
||||
if err != nil {
|
||||
Warnf("error for exclude pattern: %v", err)
|
||||
}
|
||||
|
||||
@@ -113,22 +113,22 @@ func runRestore(opts RestoreOptions, gopts GlobalOptions, args []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
selectExcludeFilter := func(item string, dstpath string, node *restic.Node) bool {
|
||||
matched, err := filter.List(opts.Exclude, item)
|
||||
selectExcludeFilter := func(item string, dstpath string, node *restic.Node) (bool, bool) {
|
||||
matched, childMayMatch, err := filter.List(opts.Exclude, item)
|
||||
if err != nil {
|
||||
Warnf("error for exclude pattern: %v", err)
|
||||
}
|
||||
|
||||
return !matched
|
||||
return !matched, childMayMatch
|
||||
}
|
||||
|
||||
selectIncludeFilter := func(item string, dstpath string, node *restic.Node) bool {
|
||||
matched, err := filter.List(opts.Include, item)
|
||||
selectIncludeFilter := func(item string, dstpath string, node *restic.Node) (bool, bool) {
|
||||
matched, childMayMatch, err := filter.List(opts.Include, item)
|
||||
if err != nil {
|
||||
Warnf("error for include pattern: %v", err)
|
||||
}
|
||||
|
||||
return matched
|
||||
return matched, childMayMatch
|
||||
}
|
||||
|
||||
if len(opts.Exclude) > 0 {
|
||||
|
||||
Reference in New Issue
Block a user