From 51885e45fd90e2ef4ec36ccb762ce3c484c08f59 Mon Sep 17 00:00:00 2001 From: Tanvir Date: Sun, 3 May 2026 16:17:59 +0800 Subject: [PATCH 1/2] 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 c59c8a90c39f..b5b195d4638b 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 From 4ae069fd76357ba80389c468a6f38323c25af17e Mon Sep 17 00:00:00 2001 From: Jared Wasinger Date: Sun, 3 May 2026 12:33:47 -0400 Subject: [PATCH 2/2] internal/download: clean it up --- internal/download/download.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/download/download.go b/internal/download/download.go index b5b195d4638b..b56bc8299ed6 100644 --- a/internal/download/download.go +++ b/internal/download/download.go @@ -209,11 +209,11 @@ func (db *ChecksumDB) DownloadFile(url, dstPath string) error { if resp.ContentLength > 0 { dst = newDownloadWriter(fd, resp.ContentLength) } - _, err = io.Copy(dst, resp.Body) - if closeErr := dst.Close(); err == nil { - err = closeErr + if _, err = io.Copy(dst, resp.Body); err != nil { + os.Remove(tmpfile) + return err } - if err != nil { + if err = dst.Close(); err != nil { os.Remove(tmpfile) return err }