forked from pingcap/br
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check.go
35 lines (30 loc) · 765 Bytes
/
check.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright 2020 PingCAP, Inc. Licensed under Apache-2.0.
package backup
import (
"encoding/hex"
"github.com/google/btree"
"github.com/pingcap/log"
"go.uber.org/zap"
"github.com/pingcap/br/pkg/rtree"
)
// checkDupFiles checks if there are any files are duplicated.
func checkDupFiles(rangeTree *rtree.RangeTree) {
// Name -> SHA256
files := make(map[string][]byte)
rangeTree.Ascend(func(i btree.Item) bool {
rg := i.(*rtree.Range)
for _, f := range rg.Files {
old, ok := files[f.Name]
if ok {
log.Error("dup file",
zap.String("Name", f.Name),
zap.String("SHA256_1", hex.EncodeToString(old)),
zap.String("SHA256_2", hex.EncodeToString(f.Sha256)),
)
} else {
files[f.Name] = f.Sha256
}
}
return true
})
}