mirror of
https://github.com/packwiz/packwiz.git
synced 2025-04-19 21:16:30 +02:00
Print error when a file hash only matches when uppercase
This commit is contained in:
parent
ca20d88093
commit
463848eaa0
@ -148,8 +148,14 @@ func (m Mod) DownloadFile(dest io.Writer) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
calculatedHash := hex.EncodeToString(h.Sum(nil))
|
calculatedHash := hex.EncodeToString(h.Sum(nil))
|
||||||
if calculatedHash != m.Download.Hash && strings.ToUpper(calculatedHash) != m.Download.Hash {
|
|
||||||
|
// Check if the hash of the downloaded file matches the expected hash.
|
||||||
|
// Also check if the uppercase version of the expected hash matches.
|
||||||
|
if(strings.ToUpper(calculatedHash) != m.Download.Hash) {
|
||||||
|
return errors.New(fmt.Sprintf("Hash of saved file %s only matches when uppercased. Consider changing this to prevent future issues.", m.GetFilePath()))
|
||||||
|
} else if calculatedHash != m.Download.Hash {
|
||||||
return errors.New(fmt.Sprintf("hash of saved file is invalid!\n .toml hash: %s\n download hash: %s", calculatedHash, m.Download.Hash))
|
return errors.New(fmt.Sprintf("hash of saved file is invalid!\n .toml hash: %s\n download hash: %s", calculatedHash, m.Download.Hash))
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user