From 33da51c596237e8e813d6c18e064939e4ebef445 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Wed, 15 Apr 2009 09:58:47 +0000 Subject: fetch: close downloaded file. unlink on failure --- src/fetch.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/fetch.c b/src/fetch.c index 40b8a24..9e0d930 100644 --- a/src/fetch.c +++ b/src/fetch.c @@ -95,9 +95,12 @@ static int fetch_package(struct fetch_ctx *fctx, } r = apk_istream_splice(is, fd, pkg->size, NULL, NULL); + if (fd != STDOUT_FILENO) + close(fd); if (r != pkg->size) { is->close(is); apk_error("Unable to download '%s'", file); + unlink(file); return -1; } -- cgit v1.2.3-70-g09d2