index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
author | Dave Reisner <dreisner@archlinux.org> | 2011-10-15 22:17:32 -0400 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-10-21 19:29:31 -0500 |
commit | 89edea326bd3d2f4d6feab441d2da961c715dbc0 (patch) | |
tree | f985a4db8beed3c75ccf309f4b03e601a6ff1455 /lib/libalpm | |
parent | d72487cc009f823e7a5600e018103679a947242c (diff) |
-rw-r--r-- | lib/libalpm/sync.c | 46 |
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index 6171695a..78f7da9a 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -848,6 +848,30 @@ static int find_dl_candidates(alpm_db_t *repo, alpm_list_t **files, alpm_list_t return 0; } +static int download_single_file(alpm_handle_t *handle, struct dload_payload *payload, + const char *cachedir) +{ + const alpm_list_t *server; + + for(server = payload->servers; server; server = server->next) { + const char *server_url = server->data; + size_t len; + + /* print server + filename into a buffer */ + len = strlen(server_url) + strlen(payload->remote_name) + 2; + MALLOC(payload->fileurl, len, RET_ERR(handle, ALPM_ERR_MEMORY, -1)); + snprintf(payload->fileurl, len, "%s/%s", server_url, payload->remote_name); + payload->handle = handle; + payload->allow_resume = 1; + + if(_alpm_download(payload, cachedir, NULL) != -1) { + return 0; + } + } + + return -1; +} + static int download_files(alpm_handle_t *handle, alpm_list_t **deltas) { const char *cachedir; @@ -902,27 +926,7 @@ static int download_files(alpm_handle_t *handle, alpm_list_t **deltas) EVENT(handle, ALPM_EVENT_RETRIEVE_START, NULL, NULL); for(i = files; i; i = i->next) { - struct dload_payload *payload = i->data; - const alpm_list_t *server; - int ret = -1; - - for(server = payload->servers; server; server = server->next) { - const char *server_url = server->data; - size_t len; - - /* print server + filename into a buffer */ - len = strlen(server_url) + strlen(payload->remote_name) + 2; - MALLOC(payload->fileurl, len, RET_ERR(handle, ALPM_ERR_MEMORY, -1)); - snprintf(payload->fileurl, len, "%s/%s", server_url, payload->remote_name); - payload->handle = handle; - payload->allow_resume = 1; - - ret = _alpm_download(payload, cachedir, NULL); - if(ret != -1) { - break; - } - } - if(ret == -1) { + if(download_single_file(handle, i->data, cachedir) == -1) { errors++; _alpm_log(handle, ALPM_LOG_WARNING, _("failed to retrieve some files\n")); } |