summaryrefslogtreecommitdiffstats
path: root/src/fetch.c
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2009-04-15 09:58:47 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2009-04-15 10:00:14 +0000
commit33da51c596237e8e813d6c18e064939e4ebef445 (patch)
treece445b5539cddbe99c70365a7edb9269797f4c8b /src/fetch.c
parentebe43a5e01c7a581e12db6494419098d1556f5be (diff)
downloadapk-tools-33da51c596237e8e813d6c18e064939e4ebef445.tar.bz2
apk-tools-33da51c596237e8e813d6c18e064939e4ebef445.tar.xz
fetch: close downloaded file. unlink on failure
Diffstat (limited to 'src/fetch.c')
-rw-r--r--src/fetch.c3
1 files changed, 3 insertions, 0 deletions
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;
}