From ace5cc4ed3f52a3e4da20d83963a23a2545d2183 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sun, 12 Aug 2018 22:02:59 +0200 Subject: [PATCH] ls: Only skip directory nodes Special case for Walk(): When SkipDir is returned for a non-dir node, the remaining nodes for the current tree are skipped. We don't want that. --- cmd/restic/cmd_ls.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cmd/restic/cmd_ls.go b/cmd/restic/cmd_ls.go index e6d11fa78..b49cb01f0 100644 --- a/cmd/restic/cmd_ls.go +++ b/cmd/restic/cmd_ls.go @@ -125,7 +125,15 @@ func runLs(opts LsOptions, gopts GlobalOptions, args []string) error { } } if !walk { - return false, walker.SkipNode + if node.Type == "dir" { + // signal Walk() that it should not descend into the tree. + return false, walker.SkipNode + } + + // we must not return SkipNode for non-dir nodes because + // then the remaining nodes in the same tree would be + // skipped, so return nil instead + return false, nil } // this second iteration ensures that we get an exact match