Hash compute hash of all file items, sorting them first
()
| 58 | |
| 59 | // Hash compute hash of all file items, sorting them first |
| 60 | func (files PackageFiles) Hash() uint64 { |
| 61 | sort.Sort(files) |
| 62 | |
| 63 | h := fnv.New64a() |
| 64 | |
| 65 | for _, f := range files { |
| 66 | h.Write([]byte(f.Filename)) |
| 67 | _ = binary.Write(h, binary.BigEndian, f.Checksums.Size) |
| 68 | h.Write([]byte(f.Checksums.MD5)) |
| 69 | h.Write([]byte(f.Checksums.SHA1)) |
| 70 | h.Write([]byte(f.Checksums.SHA256)) |
| 71 | } |
| 72 | |
| 73 | return h.Sum64() |
| 74 | } |
| 75 | |
| 76 | // Len returns number of files |
| 77 | func (files PackageFiles) Len() int { |