Remove special casing for casing differences, clarify error message

This commit is contained in:
Draylar 2020-10-19 17:29:54 -05:00
parent 0656d794e1
commit 1a21eca3a2

View File

@ -9,7 +9,6 @@ import (
"path/filepath"
"strconv"
"fmt"
"strings"
"github.com/BurntSushi/toml"
)
@ -150,11 +149,8 @@ func (m Mod) DownloadFile(dest io.Writer) error {
calculatedHash := hex.EncodeToString(h.Sum(nil))
// 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.\n", 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\n", calculatedHash, m.Download.Hash))
if calculatedHash != m.Download.Hash {
return errors.New(fmt.Sprintf("Hash of downloaded file does no match with expected hash!\n download hash: %s\n expected hash: %s\n", calculatedHash, m.Download.Hash))
}
return nil