From ca20d8809302341acf628117544e921965445c35 Mon Sep 17 00:00:00 2001 From: Draylar Date: Mon, 19 Oct 2020 16:57:52 -0500 Subject: [PATCH] Clarify hash mismatch error in mod.go and also check with uppercase hash --- core/mod.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/mod.go b/core/mod.go index 02c41ba..16b1384 100644 --- a/core/mod.go +++ b/core/mod.go @@ -8,6 +8,8 @@ import ( "os" "path/filepath" "strconv" + "fmt" + "strings" "github.com/BurntSushi/toml" ) @@ -146,8 +148,8 @@ func (m Mod) DownloadFile(dest io.Writer) error { } calculatedHash := hex.EncodeToString(h.Sum(nil)) - if calculatedHash != m.Download.Hash { - return errors.New("hash of saved file is invalid") + if calculatedHash != m.Download.Hash && strings.ToUpper(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 }