download: Delete the output file upon failure.

This allows ENOSPC conditions to be properly reported as such rather
than as a hash mismatch due to the availability of a truncated file.

Fixes <https://bugs.gnu.org/39993>.
Reported by Maxim Cournoyer <maxim.cournoyer@gmail.com>.

* guix/build/download.scm (url-fetch): In the failure case, delete FILE.
This commit is contained in:
Ludovic Courtès 2020-03-21 23:08:04 +01:00
parent 70236bae9e
commit 4a6ec23a97
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 7 additions and 0 deletions

View File

@ -693,6 +693,13 @@ otherwise simply ignore them."
(()
(format (current-error-port) "failed to download ~s from ~s~%"
file url)
;; Remove FILE in case we made an incomplete download, for example due
;; to ENOSPC.
(catch 'system-error
(lambda ()
(delete-file file))
(const #f))
#f))))
;;; download.scm ends here