mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-17 20:31:35 +00:00
Merge 1d4657b614 into 0ba4314321
This commit is contained in:
commit
cfac2b7c67
1 changed files with 8 additions and 3 deletions
|
|
@ -22,6 +22,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"iter"
|
"iter"
|
||||||
|
|
@ -180,12 +181,16 @@ func (db *ChecksumDB) DownloadFile(url, dstPath string) error {
|
||||||
return fmt.Errorf("no known hash for file %q", basename)
|
return fmt.Errorf("no known hash for file %q", basename)
|
||||||
}
|
}
|
||||||
// Shortcut if already downloaded.
|
// Shortcut if already downloaded.
|
||||||
if verifyHash(dstPath, hash) == nil {
|
verifyErr := verifyHash(dstPath, hash)
|
||||||
|
if verifyErr == nil {
|
||||||
fmt.Printf("%s is up-to-date\n", dstPath)
|
fmt.Printf("%s is up-to-date\n", dstPath)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
if errors.Is(verifyErr, os.ErrNotExist) {
|
||||||
fmt.Printf("%s is stale\n", dstPath)
|
fmt.Printf("%s not found, downloading\n", dstPath)
|
||||||
|
} else {
|
||||||
|
fmt.Printf("%s is stale\n", dstPath)
|
||||||
|
}
|
||||||
fmt.Printf("downloading from %s\n", url)
|
fmt.Printf("downloading from %s\n", url)
|
||||||
resp, err := http.Get(url)
|
resp, err := http.Get(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue