match the hashes version in reverse order (#156)
This commit is contained in:
parent
773d0f4d84
commit
acc0960c17
|
@ -5,6 +5,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"sort"
|
||||
|
||||
//"log"
|
||||
|
||||
|
@ -165,12 +166,19 @@ func parser_visit(path string, f os.FileInfo, err error) error {
|
|||
continue
|
||||
}
|
||||
}
|
||||
//wrong hash
|
||||
sha, err := getSHA256(path)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to get sha of %s : %v", path, err)
|
||||
}
|
||||
for version, val := range v.Versions {
|
||||
//let's reverse sort the versions to deal with hash collisions (#154)
|
||||
versions := make([]string, 0, len(v.Versions))
|
||||
for k := range v.Versions {
|
||||
versions = append(versions, k)
|
||||
}
|
||||
sort.Sort(sort.Reverse(sort.StringSlice(versions)))
|
||||
|
||||
for _, version := range versions {
|
||||
val := v.Versions[version]
|
||||
if sha != val.Digest {
|
||||
//log.Printf("matching filenames, wrong hash %s != %s -- %s", sha, val.Digest, spew.Sdump(v))
|
||||
continue
|
||||
|
|
Loading…
Reference in a new issue