fetch: close downloaded file. unlink on failure

cute-signatures
Natanael Copa 2009-04-15 09:58:47 +00:00
parent ebe43a5e01
commit 33da51c596
1 changed files with 3 additions and 0 deletions

View File

@ -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;
}