2
2
mirror of https://github.com/octoleo/restic.git synced 2025-01-25 16:18:34 +00:00

Ignore empty lines in excludes file

Closes #915
This commit is contained in:
Alexander Neumann 2017-04-16 20:46:52 +02:00
parent 525db875b0
commit c796d84fca

View File

@ -415,13 +415,22 @@ func runBackup(opts BackupOptions, gopts GlobalOptions, args []string) error {
scanner := bufio.NewScanner(file) scanner := bufio.NewScanner(file)
for scanner.Scan() { for scanner.Scan() {
line := scanner.Text() line := strings.TrimSpace(scanner.Text())
if !strings.HasPrefix(line, "#") {
// ignore empty lines
if line == "" {
continue
}
// strip comments
if strings.HasPrefix(line, "#") {
continue
}
line = os.ExpandEnv(line) line = os.ExpandEnv(line)
opts.Excludes = append(opts.Excludes, line) opts.Excludes = append(opts.Excludes, line)
} }
} }
}
selectFilter := func(item string, fi os.FileInfo) bool { selectFilter := func(item string, fi os.FileInfo) bool {
matched, err := filter.List(opts.Excludes, item) matched, err := filter.List(opts.Excludes, item)