From b0c090c39eab4c3a2c93fa9e54087a87f4ae033d Mon Sep 17 00:00:00 2001 From: Enno Boland Date: Mon, 11 Aug 2014 20:00:20 +0200 Subject: [PATCH] lib/download.c: delete vcdiffs after applying; cleanups. --- lib/download.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/download.c b/lib/download.c index 7d1d7dd0..aec3438e 100644 --- a/lib/download.c +++ b/lib/download.c @@ -318,9 +318,11 @@ xbps_fetch_delta(struct xbps_handle *xhp, const char *basefile, const char *uri, int status, exitcode; pid_t pid; int rv = 0; - struct stat xdelta_stat; + struct stat dummystat; - if (basefile == NULL || stat(xdelta, &xdelta_stat)) { + if (basefile == NULL || + stat(basefile, &dummystat) || + stat(xdelta, &dummystat)) { goto fetch_delta_fallback; } xbps_dbg_printf(xhp, "%s: found. Trying binary diff.\n", xdelta); @@ -333,17 +335,18 @@ xbps_fetch_delta(struct xbps_handle *xhp, const char *basefile, const char *uri, tempfile = xbps_xasprintf("%s.tmp", filename); if (xbps_fetch_file_dest(xhp, durl, dname, flags) < 0) { - xbps_dbg_printf(xhp, "error while download vcdiff, fallback to full " - "download\n", xdelta); + xbps_dbg_printf(xhp, "error while downloading %s, fallback to full " + "download\n", durl); goto fetch_delta_fallback; } if ((pid = fork()) == 0) { - execl(xdelta, xdelta, "-d", "-f", "-s", basefile, dname, tempfile, NULL); + execl(xdelta, xdelta, "-d", "-f", "-s", basefile, dname, tempfile, + NULL); exit(127); } else if (pid < 0) { xbps_dbg_printf(xhp, "error while forking, fallback to full " - "download\n", xdelta); + "download\n"); goto fetch_delta_fallback; } @@ -351,6 +354,7 @@ xbps_fetch_delta(struct xbps_handle *xhp, const char *basefile, const char *uri, waitpid(pid, &status, 0); exitcode = WEXITSTATUS(status); + unlink(dname); switch(exitcode) { case 0: // success rv = 1;