mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-09 17:46:37 +00:00
internal/download: only report stale existing downloads (#34849)
## Summary Fixes #31917. `geth era-download` now only prints `is stale` when an existing downloaded file fails checksum verification. Missing files are still downloaded normally, but no longer get mislabeled as stale. ## Why `DownloadFile` used `verifyHash` for both missing files and checksum mismatches, then printed `is stale` for any error. This made first-time downloads look like corrupt or outdated files. ## Validation - `make all` - `go run ./build/ci.go test` - `go run ./build/ci.go lint` - `go run ./build/ci.go check_generate` - `go run ./build/ci.go check_baddeps` --------- Co-authored-by: Felix Lange <fjl@twurst.com>
This commit is contained in:
parent
60db25b070
commit
4ff33ba1b6
1 changed files with 4 additions and 2 deletions
|
|
@ -22,6 +22,7 @@ import (
|
|||
"bytes"
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"iter"
|
||||
|
|
@ -180,12 +181,13 @@ func (db *ChecksumDB) DownloadFile(url, dstPath string) error {
|
|||
return fmt.Errorf("no known hash for file %q", basename)
|
||||
}
|
||||
// Shortcut if already downloaded.
|
||||
if verifyHash(dstPath, hash) == nil {
|
||||
if err := verifyHash(dstPath, hash); err == nil {
|
||||
fmt.Printf("%s is up-to-date\n", dstPath)
|
||||
return nil
|
||||
} else if !errors.Is(err, os.ErrNotExist) {
|
||||
fmt.Printf("%s is stale\n", dstPath)
|
||||
}
|
||||
|
||||
fmt.Printf("%s is stale\n", dstPath)
|
||||
fmt.Printf("downloading from %s\n", url)
|
||||
resp, err := http.Get(url)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Reference in a new issue