Clarify hash mismatch error in mod.go and also check with uppercase hash

This commit is contained in:
Draylar 2020-10-19 16:57:52 -05:00
parent 36d707e622
commit ca20d88093

View File

@ -8,6 +8,8 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"strconv" "strconv"
"fmt"
"strings"
"github.com/BurntSushi/toml" "github.com/BurntSushi/toml"
) )
@ -146,8 +148,8 @@ 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 { if calculatedHash != m.Download.Hash && strings.ToUpper(calculatedHash) != m.Download.Hash {
return errors.New("hash of saved file is invalid") 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
} }