mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-09 09:36:40 +00:00
internal/download: don't discard dst.Close error (#34866)
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. --------- Co-authored-by: Jared Wasinger <j-wasinger@hotmail.com>
This commit is contained in:
parent
aaa2b66285
commit
b92c86deb7
1 changed files with 5 additions and 3 deletions
|
|
@ -211,9 +211,11 @@ func (db *ChecksumDB) DownloadFile(url, dstPath string) error {
|
|||
if resp.ContentLength > 0 {
|
||||
dst = newDownloadWriter(fd, resp.ContentLength)
|
||||
}
|
||||
_, err = io.Copy(dst, resp.Body)
|
||||
dst.Close()
|
||||
if err != nil {
|
||||
if _, err = io.Copy(dst, resp.Body); err != nil {
|
||||
os.Remove(tmpfile)
|
||||
return err
|
||||
}
|
||||
if err = dst.Close(); err != nil {
|
||||
os.Remove(tmpfile)
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue