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:
Tanvir 2026-05-03 16:17:59 +08:00
parent f0b21fa110
commit 51885e45fd

View file

@ -210,7 +210,9 @@ func (db *ChecksumDB) DownloadFile(url, dstPath string) error {
dst = newDownloadWriter(fd, resp.ContentLength)
}
_, err = io.Copy(dst, resp.Body)
dst.Close()
if closeErr := dst.Close(); err == nil {
err = closeErr
}
if err != nil {
os.Remove(tmpfile)
return err