From eae363c96fb5ffce8e88cb63c780769b1410a1f9 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Fri, 19 Aug 2011 14:25:09 -0400 Subject: [PATCH] dload: remove code duplication Signed-off-by: Dave Reisner Signed-off-by: Dan McGee --- lib/libalpm/dload.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c index e181f425..fa7d14c7 100644 --- a/lib/libalpm/dload.c +++ b/lib/libalpm/dload.c @@ -385,17 +385,17 @@ cleanup: } if(ret == 0) { + const char *realname = tempfile; if (destfile) { + realname = destfile; if(rename(tempfile, destfile)) { _alpm_log(handle, ALPM_LOG_ERROR, _("could not rename %s to %s (%s)\n"), tempfile, destfile, strerror(errno)); ret = -1; - } else if(final_file) { - STRDUP(*final_file, strrchr(destfile, '/') + 1, - RET_ERR(handle, ALPM_ERR_MEMORY, -1)); } - } else if(final_file) { - STRDUP(*final_file, strrchr(tempfile, '/') + 1, + } + if(ret != -1 && final_file) { + STRDUP(*final_file, strrchr(realname, '/') + 1, RET_ERR(handle, ALPM_ERR_MEMORY, -1)); } }