1
0
Fork 0
mirror of https://github.com/restic/restic.git synced 2024-12-23 08:16:36 +00:00

Fix bug where some folder listings were empty

This commit is contained in:
Matthew Holt 2018-08-11 17:17:43 -06:00
parent 7a468d1226
commit 11ce572894

View file

@ -100,11 +100,13 @@ func runLs(opts LsOptions, gopts GlobalOptions, args []string) error {
// apply any directory filters
if len(dirs) > 0 {
nodeDir := path.Dir(nodepath)
// this first iteration ensures we do not traverse branches that
// are not in matching trees or will not lead us to matching trees
var walk bool
for _, dir := range dirs {
approachingMatchingTree := fs.HasPathPrefix(nodepath, dir)
approachingMatchingTree := fs.HasPathPrefix(nodeDir, dir)
inMatchingTree := fs.HasPathPrefix(dir, nodepath)
// this condition is complex, but it basically requires that we
@ -117,7 +119,7 @@ func runLs(opts LsOptions, gopts GlobalOptions, args []string) error {
// to traverse subtrees that are too deep and won't match -- this
// extra check allows us to return SkipNode if we've gone TOO deep,
// which skips all its subfolders)
if approachingMatchingTree || opts.Recursive || (inMatchingTree && dir == path.Dir(nodepath)) {
if approachingMatchingTree || opts.Recursive || (inMatchingTree && dir == nodeDir) {
walk = true
break
}
@ -143,7 +145,7 @@ func runLs(opts LsOptions, gopts GlobalOptions, args []string) error {
match = true
break
}
if !opts.Recursive && path.Dir(nodepath) == dir {
if !opts.Recursive && nodeDir == dir {
match = true
break
}