mirror of
https://github.com/packwiz/packwiz.git
synced 2025-04-19 21:16:30 +02:00
Merge pull request #9 from Draylar/hash
Add more detailed errors to clarify hash issues
This commit is contained in:
commit
920f95ed53
@ -8,6 +8,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/BurntSushi/toml"
|
"github.com/BurntSushi/toml"
|
||||||
)
|
)
|
||||||
@ -146,8 +147,11 @@ func (m Mod) DownloadFile(dest io.Writer) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
calculatedHash := hex.EncodeToString(h.Sum(nil))
|
calculatedHash := hex.EncodeToString(h.Sum(nil))
|
||||||
|
|
||||||
|
// Check if the hash of the downloaded file matches the expected hash.
|
||||||
if calculatedHash != m.Download.Hash {
|
if calculatedHash != m.Download.Hash {
|
||||||
return errors.New("hash of saved file is invalid")
|
return fmt.Errorf("Hash of downloaded file does not match with expected hash!\n download hash: %s\n expected hash: %s\n", calculatedHash, m.Download.Hash)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user