mirror of
https://github.com/packwiz/packwiz.git
synced 2025-11-19 01:24:32 +01:00
Handle uppercase hashes properly (case-fold compare or normalise to lowercase)
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user