internal/download: close dst on io.Copy error (#34910)
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Keeper Build (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run

This commit is contained in:
rayoo 2026-05-10 19:43:40 +08:00 committed by GitHub
parent 7facf9c129
commit f63c265092
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

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