diff --git a/core/download.go b/core/download.go index 79fc89d..7073041 100644 --- a/core/download.go +++ b/core/download.go @@ -299,7 +299,7 @@ func (c *CacheIndex) getHashesMap(i int) map[string]string { func (c *CacheIndex) GetHandleFromHash(hashFormat string, hash string) *CacheIndexHandle { storedHashFmtList, hasStoredHashFmt := c.Hashes[hashFormat] if hasStoredHashFmt { - hashIdx := slices.Index(storedHashFmtList, hash) + hashIdx := slices.Index(storedHashFmtList, strings.ToLower(hash)) if hashIdx > -1 { return &CacheIndexHandle{ index: c, @@ -322,7 +322,7 @@ func (c *CacheIndex) GetHandleFromHashForce(hashFormat string, hash string) (*Ca c.Hashes[hashFormat] = storedHashFmtList // Rehash every file that doesn't have this hash with this hash for hashIdx, curHash := range storedHashFmtList { - if curHash == hash { + if strings.EqualFold(curHash, hash) { return &CacheIndexHandle{ index: c, hashIdx: hashIdx, @@ -334,7 +334,7 @@ func (c *CacheIndex) GetHandleFromHashForce(hashFormat string, hash string) (*Ca if err != nil { return nil, fmt.Errorf("failed to rehash %s: %w", c.Hashes[cacheHashFormat][hashIdx], err) } - if storedHashFmtList[hashIdx] == hash { + if strings.EqualFold(storedHashFmtList[hashIdx], hash) { return &CacheIndexHandle{ index: c, hashIdx: hashIdx, @@ -353,7 +353,7 @@ func (c *CacheIndex) GetHandleFromHashForce(hashFormat string, hash string) (*Ca if err != nil { return nil, fmt.Errorf("failed to rehash %s: %w", cacheHash, err) } - if storedHashFmtList[hashIdx] == hash { + if strings.EqualFold(storedHashFmtList[hashIdx], hash) { return &CacheIndexHandle{ index: c, hashIdx: hashIdx, @@ -399,7 +399,7 @@ func (c *CacheIndex) NewHandleFromHashes(hashes map[string]string) (*CacheIndexH if handle != nil { // Add hashes to handle for hashFormat2, hash2 := range hashes { - handle.Hashes[hashFormat2] = hash2 + handle.Hashes[hashFormat2] = strings.ToLower(hash2) } return handle, true } diff --git a/core/index.go b/core/index.go index 2acc749..77dd49d 100644 --- a/core/index.go +++ b/core/index.go @@ -400,7 +400,7 @@ func (in Index) SaveFile(f IndexFile, dest io.Writer) error { } calculatedHash := h.HashToString(h.Sum(nil)) - if calculatedHash != f.Hash && !viper.GetBool("no-internal-hashes") { + if !strings.EqualFold(calculatedHash, f.Hash) && !viper.GetBool("no-internal-hashes") { return errors.New("hash of saved file is invalid") }