forked from TrueCloudLab/restic
fix: move include and exclude pattern validations to top
This commit is contained in:
parent
fdf2e4ed0e
commit
14d2799b44
1 changed files with 10 additions and 10 deletions
|
@ -73,6 +73,16 @@ func runRestore(ctx context.Context, opts RestoreOptions, gopts GlobalOptions,
|
||||||
hasExcludes := len(opts.Excludes) > 0 || len(opts.InsensitiveExcludes) > 0
|
hasExcludes := len(opts.Excludes) > 0 || len(opts.InsensitiveExcludes) > 0
|
||||||
hasIncludes := len(opts.Includes) > 0 || len(opts.InsensitiveIncludes) > 0
|
hasIncludes := len(opts.Includes) > 0 || len(opts.InsensitiveIncludes) > 0
|
||||||
|
|
||||||
|
excludePatterns, err := opts.excludePatternOptions.CollectPatterns()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
includePatterns, err := opts.includePatternOptions.CollectPatterns()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case len(args) == 0:
|
case len(args) == 0:
|
||||||
return errors.Fatal("no snapshot ID specified")
|
return errors.Fatal("no snapshot ID specified")
|
||||||
|
@ -139,11 +149,6 @@ func runRestore(ctx context.Context, opts RestoreOptions, gopts GlobalOptions,
|
||||||
msg.E("Warning: %s\n", message)
|
msg.E("Warning: %s\n", message)
|
||||||
}
|
}
|
||||||
|
|
||||||
excludePatterns, err := opts.excludePatternOptions.CollectPatterns()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
selectExcludeFilter := func(item string, _ string, node *restic.Node) (selectedForRestore bool, childMayBeSelected bool) {
|
selectExcludeFilter := func(item string, _ string, node *restic.Node) (selectedForRestore bool, childMayBeSelected bool) {
|
||||||
for _, rejectFn := range excludePatterns {
|
for _, rejectFn := range excludePatterns {
|
||||||
matched := rejectFn(item)
|
matched := rejectFn(item)
|
||||||
|
@ -160,11 +165,6 @@ func runRestore(ctx context.Context, opts RestoreOptions, gopts GlobalOptions,
|
||||||
return selectedForRestore, childMayBeSelected
|
return selectedForRestore, childMayBeSelected
|
||||||
}
|
}
|
||||||
|
|
||||||
includePatterns, err := opts.includePatternOptions.CollectPatterns()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
selectIncludeFilter := func(item string, _ string, node *restic.Node) (selectedForRestore bool, childMayBeSelected bool) {
|
selectIncludeFilter := func(item string, _ string, node *restic.Node) (selectedForRestore bool, childMayBeSelected bool) {
|
||||||
for _, includeFn := range includePatterns {
|
for _, includeFn := range includePatterns {
|
||||||
selectedForRestore, childMayBeSelected = includeFn(item)
|
selectedForRestore, childMayBeSelected = includeFn(item)
|
||||||
|
|
Loading…
Reference in a new issue