archiver: Read files/dirs in order

This commit is contained in:
Alexander Neumann 2018-05-12 23:07:16 +02:00
parent 256104111d
commit 526956af35

View file

@ -480,7 +480,16 @@ func (arch *Archiver) SaveTree(ctx context.Context, snPath string, atree *Tree,
futureNodes := make(map[string]FutureNode)
for name, subatree := range atree.Nodes {
// iterate over the nodes of atree in lexicographic (=deterministic) order
names := make([]string, 0, len(atree.Nodes))
for name := range atree.Nodes {
names = append(names, name)
}
sort.Stable(sort.StringSlice(names))
for _, name := range names {
subatree := atree.Nodes[name]
// test if context has been cancelled
if ctx.Err() != nil {
return nil, ctx.Err()