From 51885e45fd90e2ef4ec36ccb762ce3c484c08f59 Mon Sep 17 00:00:00 2001 From: Tanvir Date: Sun, 3 May 2026 16:17:59 +0800 Subject: [PATCH] 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. --- internal/download/download.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/download/download.go b/internal/download/download.go index c59c8a90c3..b5b195d463 100644 --- a/internal/download/download.go +++ b/internal/download/download.go @@ -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