mirror of
https://github.com/octoleo/restic.git
synced 2024-12-23 11:28:54 +00:00
Merge pull request #1851 from restic/fix-1849
walker: Don't ignore empty trees by default
This commit is contained in:
commit
c7a8086c19
@ -63,6 +63,10 @@ func Walk(ctx context.Context, repo TreeLoader, root restic.ID, ignoreTrees rest
|
||||
func walk(ctx context.Context, repo TreeLoader, prefix string, tree *restic.Tree, ignoreTrees restic.IDSet, walkFn WalkFunc) (ignore bool, err error) {
|
||||
var allNodesIgnored = true
|
||||
|
||||
if len(tree.Nodes) == 0 {
|
||||
allNodesIgnored = false
|
||||
}
|
||||
|
||||
sort.Slice(tree.Nodes, func(i, j int) bool {
|
||||
return tree.Nodes[i].Name < tree.Nodes[j].Name
|
||||
})
|
||||
|
@ -400,6 +400,62 @@ func TestWalker(t *testing.T) {
|
||||
),
|
||||
},
|
||||
},
|
||||
{
|
||||
tree: TestTree{
|
||||
"subdir1": TestTree{},
|
||||
"subdir2": TestTree{},
|
||||
"subdir3": TestTree{
|
||||
"file": TestFile{},
|
||||
},
|
||||
"subdir4": TestTree{
|
||||
"file": TestFile{},
|
||||
},
|
||||
"subdir5": TestTree{},
|
||||
"subdir6": TestTree{},
|
||||
},
|
||||
checks: []checkFunc{
|
||||
checkItemOrder([]string{
|
||||
"/",
|
||||
"/subdir1",
|
||||
"/subdir2",
|
||||
"/subdir3",
|
||||
"/subdir3/file",
|
||||
"/subdir4",
|
||||
"/subdir4/file",
|
||||
"/subdir5",
|
||||
"/subdir6",
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
tree: TestTree{
|
||||
"subdir1": TestTree{},
|
||||
"subdir2": TestTree{},
|
||||
"subdir3": TestTree{
|
||||
"file": TestFile{},
|
||||
},
|
||||
"subdir4": TestTree{},
|
||||
"subdir5": TestTree{
|
||||
"file": TestFile{},
|
||||
},
|
||||
"subdir6": TestTree{},
|
||||
},
|
||||
checks: []checkFunc{
|
||||
checkIgnore(
|
||||
map[string]struct{}{}, map[string]bool{
|
||||
"/subdir2": true,
|
||||
}, []string{
|
||||
"/",
|
||||
"/subdir1",
|
||||
"/subdir2",
|
||||
"/subdir3",
|
||||
"/subdir3/file",
|
||||
"/subdir5",
|
||||
"/subdir5/file",
|
||||
},
|
||||
),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
Loading…
Reference in New Issue
Block a user