Don't push directories into the backup unless associated with a file

This commit is contained in:
Dane Everitt
2020-08-27 19:55:43 -07:00
parent a7ca6b2e34
commit 68ab705aac

View File

@@ -773,10 +773,13 @@ func (fs *Filesystem) GetIncludedFiles(dir string, ignored []string) (*backup.In
} }
} }
// Avoid unnecessary parsing if there are no ignored files, nothing will match anyways // Only push files into the result array since archives can't create an empty directory within them.
// so no reason to call the function. if !e.IsDir() {
if len(ignored) == 0 || !i.MatchesPath(strings.TrimPrefix(sp, fs.Path()+"/")) { // Avoid unnecessary parsing if there are no ignored files, nothing will match anyways
inc.Push(sp) // so no reason to call the function.
if len(ignored) == 0 || !i.MatchesPath(strings.TrimPrefix(sp, fs.Path()+"/")) {
inc.Push(sp)
}
} }
// We can't just abort if the path is technically ignored. It is possible there is a nested // We can't just abort if the path is technically ignored. It is possible there is a nested