summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/libalpm/dload.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c
index bc2a761b..d9e9488a 100644
--- a/lib/libalpm/dload.c
+++ b/lib/libalpm/dload.c
@@ -142,6 +142,18 @@ static int curl_gethost(const char *url, char *buffer)
return 0;
}
+static int utimes_long(const char *path, long time)
+{
+ if(time != -1) {
+ struct timeval tv[2];
+ memset(&tv, 0, sizeof(tv));
+ tv[0].tv_sec = tv[1].tv_sec = time;
+ return utimes(path, tv);
+ }
+ return 0;
+}
+
+
static int curl_download_internal(const char *url, const char *localpath,
int force)
{
@@ -265,35 +277,23 @@ static int curl_download_internal(const char *url, const char *localpath,
goto cleanup;
}
- fclose(localf);
- localf = NULL;
-
- /* set the times on the file to the same as that of the remote file */
- if(remote_time != -1) {
- struct timeval tv[2];
- memset(&tv, 0, sizeof(tv));
- tv[0].tv_sec = tv[1].tv_sec = remote_time;
- utimes(tempfile, tv);
- }
- rename(tempfile, destfile);
ret = 0;
cleanup:
- FREE(tempfile);
- FREE(destfile);
if(localf != NULL) {
- /* if we still had a local file open, we got interrupted. set the mtimes on
- * the file accordingly. */
- fflush(localf);
- if(remote_time != -1) {
- struct timeval tv[2];
- memset(&tv, 0, sizeof(tv));
- tv[0].tv_sec = tv[1].tv_sec = remote_time;
- futimes(fileno(localf), tv);
- }
fclose(localf);
+ utimes_long(tempfile, remote_time);
}
+ /* TODO: A signature download will need to return success here as well before
+ * we're willing to rotate the new file into place. */
+ if(ret == 0) {
+ rename(tempfile, destfile);
+ }
+
+ FREE(tempfile);
+ FREE(destfile);
+
/* restore the old signal handlers */
sigaction(SIGINT, &sig_int[OLD], NULL);
sigaction(SIGPIPE, &sig_pipe[OLD], NULL);