- digestOur := hex.EncodeToString(hasher.Sum(nil))
- if digestOur == digestTheir {
- fmt.Println(f.Name, digestName, "good")
- } else {
- fmt.Println(
- "Hash does not match:", f.Name, digestName,
- "our:", digestOur,
- "their:", digestTheir,
- )
- bad = true
- continue
+ }
+
+ fullPath := toCheck[f.Name]
+ if !(len(toCheck) == 0 || fullPath != "") {
+ continue
+ }
+ if fullPath == "" {
+ fullPath = f.Name
+ }
+ s, err := os.Stat(fullPath)
+ if err != nil {
+ fmt.Println(err)
+ bad = true
+ continue
+ }
+ if uint64(s.Size()) != f.Size {
+ fmt.Println("size mismatch",
+ f.Name, "our:", s.Size(), "their:", f.Size)
+ bad = true
+ continue
+ }
+
+ hasher := meta4ra.NewHasher(*hashes)
+ var hashTheir string
+ var hashName string
+ for i, name := range hasher.Names {
+ for _, h := range f.Hashes {
+ if h.Type == name {
+ hasher.Names = []string{name}
+ hasher.Cmds = append(hasher.Cmds[:0], hasher.Cmds[i])
+ hasher.Ins = append(hasher.Ins[:0], hasher.Ins[i])
+ hasher.Outs = append(hasher.Outs[:0], hasher.Outs[i])
+ hashName = name
+ hashTheir = h.Hash
+ goto HashFound
+ }