mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-08 07:58:40 +00:00
internal/download: don't discard dst.Close error
When `io.Copy` succeeds but the buffered `Close` fails (e.g. disk full on `Flush`), the error was swallowed and verification reported a misleading hash mismatch instead of the real I/O failure. Keep the `Close` error when `io.Copy` didn't already produce one.
This commit is contained in:
parent
f0b21fa110
commit
51885e45fd
1 changed files with 3 additions and 1 deletions
|
|
@ -210,7 +210,9 @@ func (db *ChecksumDB) DownloadFile(url, dstPath string) error {
|
||||||
dst = newDownloadWriter(fd, resp.ContentLength)
|
dst = newDownloadWriter(fd, resp.ContentLength)
|
||||||
}
|
}
|
||||||
_, err = io.Copy(dst, resp.Body)
|
_, err = io.Copy(dst, resp.Body)
|
||||||
dst.Close()
|
if closeErr := dst.Close(); err == nil {
|
||||||
|
err = closeErr
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
os.Remove(tmpfile)
|
os.Remove(tmpfile)
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue