forked from TrueCloudLab/restic
Return an error when exclude files cannot be read
This commit is contained in:
parent
67535e00a8
commit
fb74de6360
1 changed files with 8 additions and 5 deletions
|
@ -210,7 +210,11 @@ func collectRejectFuncs(opts BackupOptions, repo *repository.Repository, targets
|
||||||
|
|
||||||
// add patterns from file
|
// add patterns from file
|
||||||
if len(opts.ExcludeFiles) > 0 {
|
if len(opts.ExcludeFiles) > 0 {
|
||||||
opts.Excludes = append(opts.Excludes, readExcludePatternsFromFiles(opts.ExcludeFiles)...)
|
excludes, err := readExcludePatternsFromFiles(opts.ExcludeFiles)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
opts.Excludes = append(opts.Excludes, excludes...)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(opts.Excludes) > 0 {
|
if len(opts.Excludes) > 0 {
|
||||||
|
@ -238,7 +242,7 @@ func collectRejectFuncs(opts BackupOptions, repo *repository.Repository, targets
|
||||||
// and comment lines are ignored. For each remaining pattern, environment
|
// and comment lines are ignored. For each remaining pattern, environment
|
||||||
// variables are resolved. For adding a literal dollar sign ($), write $$ to
|
// variables are resolved. For adding a literal dollar sign ($), write $$ to
|
||||||
// the file.
|
// the file.
|
||||||
func readExcludePatternsFromFiles(excludeFiles []string) []string {
|
func readExcludePatternsFromFiles(excludeFiles []string) ([]string, error) {
|
||||||
getenvOrDollar := func(s string) string {
|
getenvOrDollar := func(s string) string {
|
||||||
if s == "$" {
|
if s == "$" {
|
||||||
return "$"
|
return "$"
|
||||||
|
@ -274,11 +278,10 @@ func readExcludePatternsFromFiles(excludeFiles []string) []string {
|
||||||
return scanner.Err()
|
return scanner.Err()
|
||||||
}()
|
}()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Warnf("error reading exclude patterns: %v:", err)
|
return nil, err
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return excludes
|
return excludes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// collectTargets returns a list of target files/dirs from several sources.
|
// collectTargets returns a list of target files/dirs from several sources.
|
||||||
|
|
Loading…
Reference in a new issue